Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DllMain defined both in mfcs40.lib and MSVCRT.lib

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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

972 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