Solved

DllMain defined both in mfcs40.lib and MSVCRT.lib

Posted on 1997-04-11
3
577 Views
Last Modified: 2013-11-20
I have created a regular DLL that uses MFC as a shared
library. The DLL contains some dialogs, and is called
through an exported (non-MFC) class.
This works fine.
After exiting from MSDev and opening the project again, I
add one more source file to the project, or change a
#define. Everything compiles OK, but I get the link error:

mfcs40.lib(dllmodul.obj) : error LNK2005: _DllMain@12
already defined in MSVCRT.lib(dllmain.obj)

I tried replicating this behavior in a small project, but
the error didn't show up.
Is this an MSDev bug? Is there a workaround?
0
Comment
Question by:yonat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
sapek earned 100 total points
ID: 1300975
I had exactly the same error a few days ago. I don't know the reason for this to happen but I have a workaround. Go to your project build setting link page, select Input category and add mfcs40.lib (mfcs40d.lib for debug build) *both* to "Object/Library modules:" and "Ignore libraries:" edit boxes. I believe it help by making linker to look at mfcs40.lib after MSVCRT.lib.

Hope this also work for you.

Adam
0
 
LVL 5

Author Comment

by:yonat
ID: 1300976
Thanks a million!
0
 
LVL 5

Author Comment

by:yonat
ID: 1300977
I have found the reason!

This error occurs when one of the cpp files in the project does not include any MFC header and uses new/delete. MFC code needs its own new/delete ops and they conflict with the ones that non-MFC C++ code links to.

The solution: put #include <afx.h> (or #include "stdafx.h") in all non-MFC C++ sources.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question