Click here to Skip to main content
11,934,783 members (41,874 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked

Solve error LNK2005: _DllMain@12 already defined in msvcrtd.lib(dllmain.obj) in MFC Projects

, 5 Mar 2012 CPOL
Rate this:
Please Sign up or sign in to vote.


Sometimes A LNK2005 error occurs when the CRT library and MFC libraries are linked in the wrong order in Visual C++. As a result you would see the error described in the subject line.

How to Solve

Declare the mfc80ud.lib and mfcs80ud.lib in the Additional Dependancies field in the Linker Tab of Visual Studio and this problem should be resolved. 

Here 80 corresponds to the version of MS Visual Studio and 'd' states that it is debug dll.
For example,

msvcr90d.dll = VS 2008 debug xxxx.dl,
msvcr80d.dll = VS 2005 debug xxxx.dl,
msvcr71d.dll = VS 2003 debug xxxx.dl,
msvcr70d.dll = VS 2002 debug xxxx.dl, 
For Release dlls of-course you will not have 'd' suffix at the end of your dll name.

Thanks to Lakamraju Raghuram for the clarifications.

Points of Interest

I faced this problem while compiling a DLL, so probably the solution is applicable for dlls only.


Tip uploaded : 4th March, 2012.

Tip updated  : 5th March, 2012 


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mukit, Ataul
Chief Technology Officer Rational Technologies
Bangladesh Bangladesh
Your Lord does not like people who waste by extravagance, and only the righteous C s, and does so in increments, and they are of those people who are mindful of what memory and time has in offer and they waste none of it.

You may also be interested in...

Comments and Discussions

QuestionCheck if you have both _USRDLL and _AFXDLL defined Pin
Dan Konigsbach17-Jul-13 15:48
memberDan Konigsbach17-Jul-13 15:48 
QuestionVisual Studio 2010 Pin
jpat3472110-Feb-13 18:22
memberjpat3472110-Feb-13 18:22 
AnswerRe: Visual Studio 2010 Pin
Mukit, Ataul11-Feb-13 1:17
memberMukit, Ataul11-Feb-13 1:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151126.1 | Last Updated 5 Mar 2012
Article Copyright 2012 by Mukit, Ataul
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid