VS报错 error LNK2005: [email protected] 已经在 MSVCRTD.lib(dllmain.obj) 中定义

链接报错:

错误 33 error LNK2005: [email protected] 已经在 MSVCRTD.lib(dllmain.obj) 中定义 E:\客户问题\w_王鹏\EventLibTest_TibrvAlternative_MultiEnv-4-0.3将 DTSSysEvent.xml做为单独参数传给每个环境\EventLibTest_TibrvAlternative_MultiEnv\Win32 \APPFL\EventLibMultiEnvDLL\mfcs100d.lib(dllmodul.obj) EventLibMultiEnvDLL (Visual Studio 2010)

解决方法:

项目-》属性-》配置属性-》C/C++/预处理器,去掉预处理器定义中的_USRDLL 即可

另外:

常见预处理器设置的意义:

http://blog.csdn.net/honker110/article/details/6120810

常见的编译参数VC建立项目时总会定义"Win32"。控制台程序会定义"_CONSOLE",否则会定义"_WINDOWS"。Debug版定义"_DEBUG",Release版定义"NDEBUG"

  与MFC DLL有关的编译常数包括:

  _WINDLL 表示要做一个用到MFC的DLL

  _USRDLL 表示做一个用户DLL(相对MFC扩展DLL而言)

  _AFXDLL 表示使用MFC动态链接库的 regular DLL

  _AFXEXT 表示要做一个MFC扩展DLL

  所以:

  Regular, statically linked to MFC _WINDLL,_USRDLL

  Regular, using the shared MFC DLL _WINDLL,_USRDLL,_AFXDLL

  Extension DLL _WINDLL,_AFXDLL,_AFXEXT

Building Your DLL

When compiling regular DLLs that statically link to MFC, the
symbols "_USRDLL" and "_WINDLL" must be defined. Your DLL code must also
be compiled with the following compiler switches:

•/D_WINDLL      signifies the compilation is for a DLL

•/D_USRDLL      specifies you are building a regular DLL

When compiling regularDLLs that statically link to MFC, the symbols
"_USR DLL" and"_WINDLL" must be defined. Your DLL code must also be
compile dwith the following compiler switches:

When compiling regular DLLs that dynamicallylink to MFC, you must
define t he above symbols and use the above compilerswitches.
Additionally, the sy mbol "_AFXDLL" must be definedand your DLL code
must be compiled with:

•/D_AFXDLL     specifies that you are building a regular DLL that dynamicall y links to MFC

The interfaces (APIs) between the application and the DLL must
beexplicitlyexported. It is recommended that you define your interfaces
to be lowbandw idth, sticking to C interfaces where possible. More
direct C interfaces areeasi er to maintain than more
complex C++ classes.

Place your APIs in aseparate header that can be included by both C
and C++files (that way you won‘tlimit your DLL customers to C++
programmers). Se e the header ScreenCap.h in theMFC Advanced Concepts
sample DLLScreen Cap for an example. To export yourfunctions,
enter them in theEXPORTSs ection of your moduledefinition file (.DEF)
or include__declspec(dllexpor t)on yourfunction definitions.
Use__declspec(dllimport)to import thesefunctions into the client
executable.

You must add theAFX_MANAGE_STATEmacro at the beginning of all the e
xportedfunctions in regular DLLs that dynamically link to MFC to set
the curr ent modulestate to the one for the DLL. This is done by adding
the followingline of codeto the beginning of
functions exported from the DLL:

AFX_MANAGE_STATE(AfxGetStaticModuleState( ))

WinMain->DllMain

The MFC library defines the standard Win32DllMain entry point that
initializ es yourCWinAppderived object as in a normal MFC application.
Placeall DLL-specific initialization in theInitInstancememberfunction as
in a normal MFC application.

经验证可行

转自 http://blog.csdn.net/tian_jinping/article/details/14168919

或使用如下方法,是的mfc库先于msvcrtd.lib链接

[email protected] 已经在 MSVCRTD.lib(dllmain.obj) 中定义
   VC2005解决办法:
1)Debug版本:
项目-属性-链接器-输入:忽略特定库中输入mfc80d.lib;mfcs80d.lib
项目-属性-链接器-附加依赖项:mfc80d.lib;mfcs80d.lib
   就可以保证mfc80d和mfcs80d先于MSVCRTD.lib链接,OK,成功
2)Release版本
   与Debug版本不同在于mfc80.lib;mfcs80.lib

时间: 2024-12-26 01:57:45

VS报错 error LNK2005: [email protected] 已经在 MSVCRTD.lib(dllmain.obj) 中定义的相关文章

VC编译错误:msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::t.... 已经在 libcmtd.lib(typinfo.obj) 中定义

1>msvcrtd.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" ([email protected]@[email protected]@@Z) 已经在 libcmtd.lib(typinfo.obj) 中定义1>msvcrtd.lib(ti_inst.obj) : error LNK2005: "

error LNK2005: DDX_Control 已经在 uafxcwd.lib(wincore2.obj) 中定义

编译错误提示: 1>afxnmcdd.lib(wincore2.obj) : error LNK2005: "void __stdcall DDX_Control(classCDataExchange *,int,class CWnd &)" ([email protected]@[email protected]@[email protected]@@Z)already defined in nafxcwd.lib(wincore2.obj) 1>afxnmcdd

[转帖] 关于形如--error LNK2005: xxx 已经在 msvcrtd.lib ( MSVCR90D.dll ) 中定义--的问题分析解决

原文:http://www.cnblogs.com/qinfengxiaoyue/archive/2013/02/01/2889668.html 转自:http://hi.baidu.com/qinfengxiaoyue/item/ff262ccfb53b4c2ba0b50a89 引自:http://blog.csdn.net/sptoor/archive/2011/02/23/6203376.aspx 对全文有改动. 提示:阅读前需要对静态库(.lib).动态库(.dll).导入库(这个还是.

2>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义

使用VS2010,在FireBreath里面调用ortp库和Speex库.编译的时候出现错误: 2>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义 事实上有非常多类似的打印. "属性"->"链接器"->"输入"->"忽略特定默认库" 将LIBCMTD.lib写入就能够了:

VS2015 C++编译报错 error:LNK2005 _main 已经在 *.obj 中定义

一个项目里只能有一个main函数, 如果出现 error:LNK2005 的错误,那么需要检查你是不是有两个源代码文件中都定义了main函数. 例如: 如果在a.cpp中定义了main函数,在b.cpp中也定义main函数,编译执行就会报 error:LNK2005 的错误. 原文地址:https://www.cnblogs.com/alpha-w/p/10415997.html

2>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义

使用VS2010,在FireBreath里面调用ortp库和Speex库,编译的时候出现错误: 其实有很多类似的打印. "属性"->"链接器"->"输入"->"忽略特定默认库" 将LIBCMTD.lib写入就可以了:

1>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _strncmp 已经在 libcmtd.lib(strncmp.obj) 中定义

原来在MFC ActiveX里面也是可以使用eXosip库的.... 悲剧总是在不经意间就发生在我的身上, 这个错误,莫名其妙的就出现了,同事编译好的eXosip库,在vs2010用的好好的,我在MFC里面去用就出现了这样的问题: 实例很多种方法,大部分说的就可MTD相关: 后来对比了同事的项目属性,使用的不是这个,是MT,打开他编译库的工程,发现也不是MTD,于是将工程拿出来,重新使用MTD编译出来的库,放在我那个里面使用就没有问题了.

error LNK2005: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) 已经在 LIBCMTD.lib(new.obj) 中

在编译文章: 使用GetAdaptersAddresses函数获取物理MAC地址中的代码时,出现以下错误: 错误 1 error LNK2005: "void * __cdecl operator new(unsigned int)" ([email protected]@Z) 已经在 LIBCMTD.lib(new.obj) 中定义 F:\CcProjects\获取网卡物理地址MAC地址\获取网卡物理地址MAC地址\uafxcwd.lib(afxmem.obj) 获取网卡物理地址MA

解决CentOS7下运行docker容器时出现的报错Error resolving syscall name...

最近在研究docker!在虚拟机centos7中运行docker经常会有: [[email protected] docker]$ docker run -it lin/centos6 /bin/bash 2016/11/08 19:38:53 Error resolving syscall name execveat: could not resolve name to syscall - ignoring syscall. 2016/11/08 19:38:53 Error resolvin