不知道有没有人遇到过,MFC的lib和VCRT的lib冲突的问题.

Kevin_qing 2001-07-19 10:27:19
加精

mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj); second definition ignored

这是在一个使用MFC的win32dll(不是MFC extended的) 并且里面使用了stdio的一些函数。
最开始编译的时候没有问题,但是在工程关闭后重新打开几次就会出现这个连接错误.
重新建立工程后错误又消失,再多打开几次又有问题了。

这个错误的原因应该是因为MFC写的dll里面没有自己的dllmain,所以需要连接默认的MFC42D里面的,但是因为又用到了VCRT的东西,里面也存在dllmain,linker不知道连接哪个所以报错,但是为什么最开始的built并不会出错呢?

谁知道是怎么回事?????

...全文
210 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
colarcui 2002-01-29
  • 打赏
  • 举报
回复
ok
Kevin_qing 2001-08-08
  • 打赏
  • 举报
回复
结帐
Kevin_qing 2001-08-01
  • 打赏
  • 举报
回复
嘿,删了我的跟帖,终于可以发言了。。。
这个问题的解决办法是:
使用lib命令,从mfcs42d.lib里面解出dllmodul.obj
将这个文件加入到link的obj文件里面。
搞定······哈哈
Kevin_qing 2001-07-19
  • 打赏
  • 举报
回复
MSDN solution I:
不可行,因为如果忽略任何一个lib,都会造成很多的未连接符号。
MSDN solution II:
也不可行~因为MFCs42d和MSVCRTD又不是我写的,怎么改啊·······



Kevin_qing 2001-07-19
  • 打赏
  • 举报
回复
wolf721() ,能不能帮忙找找以前的帖子,我想看一下
thx a lot
masterz 2001-07-19
  • 打赏
  • 举报
回复
Project settings->C/C++ tab
Category: 选Code Generation
Use run-time library: 改变这里的选项
一般来说是因为你有的库用的是single threaded,有的是multithreaded.混合起来用就有以上的问题
wolf721 2001-07-19
  • 打赏
  • 举报
回复
以前见过这个问题帖子,好象是链接顺序不对的缘故。
下面是MSDN里面的解决办法:
RESOLUTION
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's causing the problem and correct it.

Solution One - Force Linker to Link Libraries in Correct Order
Open the Project Settings dialog box by clicking Settings on the Build menu.


in the Settings For view, select (highlight) the project configuration that's getting the link errors.


Click the Link tab.


Select INPUT in the Category combo box.


In the Libraries to Ignore edit box, insert the library names (for example, Nafxcwd.lib Libcmtd.lib)

NOTE: The linker command line equivalent in /NOD:<library name>


In the Object/library Modules edit box, insert the library names. You must ensure that these are listed in order and as the first two libraries in the line (for example, Nafxcwd.lib Libcmtd.lib).


Solution Two - Find the Problem Module and Correct It
Perform the following steps to see the current library link order:


Open the Project Settings dialog box by clicking Settings on the Build menu.


In the Settings For view, Select (highlight) the project configuration that's getting the link errors .


Click the Link tab.


Type the following in the Project Options dialog box:
/verbose:lib



Rebuild your project. The libraries will now be listed in the output window during the linking process.




Kevin_qing 2001-07-19
  • 打赏
  • 举报
回复
问题我已经解决了,我还想看看有没有人提出什么好的看法和建议
loocc 2001-07-19
  • 打赏
  • 举报
回复
我也遇过相似的情况,也不知道怎么解决
push
Kevin_qing 2001-07-19
  • 打赏
  • 举报
回复
push
wolf721 2001-07-19
  • 打赏
  • 举报
回复
MSDN中条目:
PRB: LNK2005 Errors When Link C Run-Time Libs Before MFC Libs

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧