MFC ATL dll link error
-
Sorry guys I'm pretty new to ATL and COM stuff. The project is a shell extension with MFC support. Been looking at the tutorials on it over and over but can't find out how to fix this problem. After starting a new project I can get it to work. Then after compiling a few times (changing nothing) it ends up giving this link error. It starts happening randomly but never goes away once I first get it. Linking... mfcs42.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj) mfcs42.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj); second definition ignored Creating library ReleaseMinSize/program.lib and object ReleaseMinSize/program.exp ReleaseMinSize/program.dll : fatal error LNK1169: one or more multiply defined symbols found I can start a new project, transplant the code, and have it working for a while till I get this again. I've had to include afxcmn.h, and change my .cpp files to automatic use of precompiled headers. But apart from that I've not really changed anything. I can get the code to work fine in a nonMFC dll (without using MFC components). Removing all MFC statements I've added doesn't help either. Any idea on how to fix this? Thanks -Neil
-
Sorry guys I'm pretty new to ATL and COM stuff. The project is a shell extension with MFC support. Been looking at the tutorials on it over and over but can't find out how to fix this problem. After starting a new project I can get it to work. Then after compiling a few times (changing nothing) it ends up giving this link error. It starts happening randomly but never goes away once I first get it. Linking... mfcs42.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj) mfcs42.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj); second definition ignored Creating library ReleaseMinSize/program.lib and object ReleaseMinSize/program.exp ReleaseMinSize/program.dll : fatal error LNK1169: one or more multiply defined symbols found I can start a new project, transplant the code, and have it working for a while till I get this again. I've had to include afxcmn.h, and change my .cpp files to automatic use of precompiled headers. But apart from that I've not really changed anything. I can get the code to work fine in a nonMFC dll (without using MFC components). Removing all MFC statements I've added doesn't help either. Any idea on how to fix this? Thanks -Neil
Got the similar problem with MSVCRT.lib myself except my project does not link at all ;( I hope this one helps you: Look at your Project Settings -> "C/C++" tab -> "category" combo -> drop "category" combo to "Preprocessor" -> -> look at "Preprocessor definitions:" edit box. If you find _ATL_MIN_CRT, remove it for all project configurations except "Debug". This flag tells compiler not to link your project with any Microsoft Standard Runtime Libs (for minimum size). If you include "MFC support", MFC requires those runtimes linked to your project - that's where collision occurs. Since you don't have any problems while MFC's presence is disabled, that sounds like my case. Kirill.
-
Got the similar problem with MSVCRT.lib myself except my project does not link at all ;( I hope this one helps you: Look at your Project Settings -> "C/C++" tab -> "category" combo -> drop "category" combo to "Preprocessor" -> -> look at "Preprocessor definitions:" edit box. If you find _ATL_MIN_CRT, remove it for all project configurations except "Debug". This flag tells compiler not to link your project with any Microsoft Standard Runtime Libs (for minimum size). If you include "MFC support", MFC requires those runtimes linked to your project - that's where collision occurs. Since you don't have any problems while MFC's presence is disabled, that sounds like my case. Kirill.
Thanks for the reply. I haven't got _ATL_MIN_CRT in my preprocessor definitions it seems. This is what I have: WIN32,NDEBUG,_WINDOWS,_WINDLL,_AFXDLL,_MBCS,_USRDLL,_ATL_DLL Removing _ATL_DLL doesn't seem to help. Removing _AFXDLL creates more errors ofcourse. The strange thing is I can link the project after creating a new one, and notice no differences in any project settings after it starts having this link error. I've tried deleting some different generated files but that hasn't helped so far either. Any ideas? Thanks
-
Thanks for the reply. I haven't got _ATL_MIN_CRT in my preprocessor definitions it seems. This is what I have: WIN32,NDEBUG,_WINDOWS,_WINDLL,_AFXDLL,_MBCS,_USRDLL,_ATL_DLL Removing _ATL_DLL doesn't seem to help. Removing _AFXDLL creates more errors ofcourse. The strange thing is I can link the project after creating a new one, and notice no differences in any project settings after it starts having this link error. I've tried deleting some different generated files but that hasn't helped so far either. Any ideas? Thanks
Sorry guys, fixed it now. I was using memset and including memory.h in one of my classes which seemed to cause it. Although I could comment out the memset and include statements, build it, uncomment them and build again and then it'd work. Although gives a warning: LINK : warning LNK4089: all references to "MSVCIRT.dll" discarded by /OPT:REF Which is good I guess. Can't see any options or flags that may have changed to cause this though.