win32 Dll 中添加afx.h 出现如下错误 error LNK2005: _DllMain@12 already defined

时间:2023-03-09 15:54:16
win32 Dll 中添加afx.h 出现如下错误 error LNK2005: _DllMain@12 already defined

win32 Dll 中添加afx.h 出现如下错误

nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in ssmFunc.obj
nafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in ssmFunc.obj; second definition ignored
   Creating library Debug/ssmFunc.lib and object Debug/ssmFunc.exp
Debug/ssmFunc.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

ssmFunc.dll - 2 error(s), 1 warning(s)
解决方法:头文件中添加

#ifdef _X86_
extern "C" { int _afxForceUSRDLL; }
#else
extern "C" { int __afxForceUSRDLL; }
#endif