Project error LNK2005: _DllMain@12 already defined in MSVCRT.lib(dllmain.obj)

转自:
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/0b154e1c-141f-4567-bb24-1ac7c8ee2713/

When upgrading a DLL from VC6->VS2005, and you get the following:
mfcs80d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined
As suggested in the above comment, try the recommendation in the following link:

http://support.microsoft.com/default.aspx?scid=kb;en-us;q148652

if the suggestions in the above link fail, try the following:
In VS2005, select Project->Properties->Configuration Properties->Linker->Advanced
Set EntryPoint to DllMain
Save, clean & recompile.

另外,
转自 http://www.cppblog.com/NWAO/archive/2012/03/08/167403.aspx
问题:这两天在编译公司软件的一个旧版本的代码。有一个工程在link时一直报告mfcs90ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj),编译不过
解决:排除工程设置等原因后,上网查找lnk2005资料,找到了解决办法。
Step1 : Open project property--->Configuration property--->link-->Genral-->show Process 选为 VERBOSE:LIB,然后Build会看到如下内容:

1 1>Linking
2 1>Searching libraries
3 1>    Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\MSVCRTD.lib:
4 1>    Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\lib\mfcs90ud.lib:
5 1>mfcs90ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)

     据说是msvcrt和mfcs90u链接顺序不对导致的,但为什么顺序会不正确,未能找到原因,解决办法为为其强制指定顺序,
Step2: project property--->Configuration property--->link-->Additional Dependies  = mfcs90ud.lib MSVCRTD.lib (DLL名字Debug版带最后的D,Release版不带,下同)
                                                                                    -->Ignore Specific Library = MSVCRTD.lib mfcs90ud.lib
     再编译即OK
参考http://support.microsoft.com/kb/148652

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章