编译DLL时"error LNK2005: _DllMain@12 already defined"错误

来源:互联网 发布:淘宝ipad pro鉴别 编辑:程序博客网 时间:2024/05/22 01:49

编译出现如下错误


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


解决方法:

project setting->C/C++, 在category中选择Preprocessor,将preprocessor definitions中的_USRDLL删除即可。

 


网上查找过程中,MSDN也有一些应对资料


A LNK2005 error occurs when the CRT library and MFC libraries are linked in the wrong order in Visual C++

 

几种解决方案内容如下:

There are two ways to resolve this problem. The first solution involves forcing the linker to link the libraries in the correct order. The second solution allows you to find the module that is causing the problem and to correct it.

Note The following steps are based on Visual C++ 6.0.

Back to the top

Solution One: Force Linker to Link Libraries in Correct Order

To view the current library link order, follow these steps:

  1. On the Projectmenu, click Settings.
  2. In the Settings For view of theProject Settings dialog box, click to select the projectconfiguration that is getting the link errors.
  3. On the Link tab, type/verbose:lib in the Project Optionsbox.
  4. Rebuild your project. The libraries will be listed in theoutput window during the linking process.