Solved

DllMain defined both in mfcs40.lib and MSVCRT.lib

Posted on 1997-04-11
3
569 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 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now