error LNK2005: _DllMain@12 already defined in MSVCRT.lib

前端 未结 17 1927
臣服心动
臣服心动 2020-12-14 06:44

I am getting this linker error.

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

相关标签:
17条回答
  • 2020-12-14 07:09

    This can also occur if your solution has multiple projects that export the same symbols. For example if you have sub-project that builds foo.dll with a foo.def file that exports DoFoo and a sub-project for bar.dll with a bar.def file that exports DoFoo, a collision will occur and this is the error you will see when you link.

    0 讨论(0)
  • 2020-12-14 07:11

    I found this which helped me: http://support.microsoft.com/kb/148652

    Basically the linker order was incorrect. the CRT libs were getting linked before the MFC libs. Turns out, the MFC libs had to get linked FIRST, and then the CRT libs could be linked.

    Yucko Microsoft!!

    0 讨论(0)
  • 2020-12-14 07:12

    For me the direct cause was indeed a missing _afxForceUSRDLL symbol reference, but the indirect cause was a missing _USRDLL macro definition. It is defined by default by the VC wizard, but occasionally devs erase it erroneously. Here it is in more words.

    0 讨论(0)
  • 2020-12-14 07:13

    Declare the mfc80ud.lib and mfcs80ud.lib in the Additional Dependancies field in the Project Properties -> Linker Tab -> Input of Visual Studio to fix the issue.

    0 讨论(0)
  • 2020-12-14 07:15

    Just #undef the _USRDLL before including afx.h, or even better, edit your project configuration and remove the macro.

    This is the usual configuration for a MFC extension DLL: Build Settings for an MFC DLL

    0 讨论(0)
  • 2020-12-14 07:15

    Make sure you include "Stdafx.h" at the top of each .cpp file. I was getting the exact same error and had a single .cpp file that did not include this header at all. Adding the #include solved the problem.

    0 讨论(0)
提交回复
热议问题