Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DllMain defined both in mfcs40.lib and MSVCRT.lib

Posted on 1997-04-11
3
Medium Priority
?
579 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 200 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

721 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