error LNK2005: _DllMain@12 already defined in MSVCRTD.lib
2016-04-26 18:12
597 查看
本文主要分析和解决编译链接时产生的 LNK2005 错误。
【错误信息】: mfcs90ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)【分析原因】: 这篇文章:《在Visual C++中以错误的顺序链接CRT库和MFC库时出现LNK2005错误》详细分析和说明了产生这种错误的原因。 简单地说,就是产生错误的工程同时使用了CRT库和MFC库,并且链接顺序不对,CRT 库对 new、delete 和 DllMain 函数使用弱外部链接。MFC 库也包含 new、delete 和 DllMain 函数。这些函数要求先链接 MFC 库,然后再链接 CRT 库。【解决方法】:[align=left]
在“项目 -> 属性 -> 链接器 -> 命令行”栏中,输入 /verbose:lib编译参数,这样,就可以在output窗口看到链接时搜索的库的先后顺序,对于本问题,你一定可以看到类似下面的先后输出:[/align][align=left] [/align]
选择:菜单“项目”-->“设置”->链接-->Input。
在第一行“对象/库模块”中最前面输入mfcs90ud.lib;MSVCRTD.lib
在第二行“忽略库”框中,输入mfcs90ud.lib;MSVCRTD.lib。
确定,重新链接,通过![/align][align=left] [/align][align=left]【知识扩展】:
顺便普及一下编译参数/VERBOSE的其他用法。 该说明的官方网址点击:这里:
[/align][align=left][/align]
【错误信息】: mfcs90ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)【分析原因】: 这篇文章:《在Visual C++中以错误的顺序链接CRT库和MFC库时出现LNK2005错误》详细分析和说明了产生这种错误的原因。 简单地说,就是产生错误的工程同时使用了CRT库和MFC库,并且链接顺序不对,CRT 库对 new、delete 和 DllMain 函数使用弱外部链接。MFC 库也包含 new、delete 和 DllMain 函数。这些函数要求先链接 MFC 库,然后再链接 CRT 库。【解决方法】:[align=left]
在“项目 -> 属性 -> 链接器 -> 命令行”栏中,输入 /verbose:lib编译参数,这样,就可以在output窗口看到链接时搜索的库的先后顺序,对于本问题,你一定可以看到类似下面的先后输出:[/align][align=left] [/align]
ortant; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 20px; line-height: 1.3em; list-style-image: initial; list-style-type: decimal-leading-zero; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-color: initial; border-width: initial; border-color: initial;" >> Searching D:\vs2008\VC\lib\MSVCRTD.lib: ortant; padding-right: 3px !important; padding-bottom: 0px !important; padding-left: 10px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 20px; color: rgb(92, 92, 92); line-height: 1.3em; list-style-image: initial; list-style-type: decimal-leading-zero; border-top-width: medium; border-right-width: medium; border-bottom-width: medium; border-left-width: medium; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-color: initial; border-width: initial; border-color: initial;" >> Searching D:\vs2008\VC\atlmfc\lib\mfcs90ud.lib:[align=left] 由此可以看出,默认情况下,先链接了CRT库MSVCRTD.lib,然后链接的是MFC的库mfcs90ud.lib,因此,需要强制改变一下它们的链接顺序。
选择:菜单“项目”-->“设置”->链接-->Input。
在第一行“对象/库模块”中最前面输入mfcs90ud.lib;MSVCRTD.lib
在第二行“忽略库”框中,输入mfcs90ud.lib;MSVCRTD.lib。
确定,重新链接,通过![/align][align=left] [/align][align=left]【知识扩展】:
顺便普及一下编译参数/VERBOSE的其他用法。 该说明的官方网址点击:这里:
[/align][align=left][/align]
相关文章推荐
- linker command failed with exit code 1 解决
- Error launching remote program: failed to get the task for process
- SendEmail语法
- 001安卓AIDL学习记录
- SharePoint 2013 Foundation 报错: 试图调用服务应用程序时报告了失败: EndpointFailure 8313
- int main(int argc, char **argv)中参数argc与argv的意义
- STM32中开漏(open-drain,漏极开路)和推挽(push-pull)以及float input分析
- [AIR]安卓APK授权加密的研究
- node.js---sails项目开发(4)---配置MongoDB数据库连接
- 03-树3 Tree Traversals Again
- [LintCode] 逆序对 Reverse Pairs
- Leetcode 11. Container With Most Water
- RAID级别与规范
- RAID级别与规范
- Chain of Responsibility模式
- rails 提供下拉框select和select_tag用法(附加form_for, form_tag提交表单的内容)
- net::ERR_PROXY_CONNECTION_FAILED
- 异常:HibernateOptimisticLockingFailureException StaleStateException
- Debug Assertion Failed! Expression: _pFirstBlock == pHead
- 在CI框架中如何发送email?