【编程】编程语言(C++) – 编译 – MSVCRTD.LIB LIBCMTD.LIB 的顺序导致的编译错误!

在编译 JXTA-C 的时候发现一个有趣的现象,就是老是出现 LNK2005 错误


Linking…
MSVCRTD.LIB(MSVCRTD.dll) : error LNK2005: __errno already defined in LIBCMTD.LIB(dosmap.obj)
MSVCRTD.LIB(MSVCRTD.dll) : error LNK2005: _free already defined in LIBCMTD.LIB(dbgheap.obj)
MSVCRTD.LIB(MSVCRTD.dll) : error LNK2005: _realloc already defined in LIBCMTD.LIB(dbgheap.obj)
MSVCRTD.LIB(MSVCRTD.dll) : error LNK2005: _malloc already defined in LIBCMTD.LIB(dbgheap.obj)
MSVCRTD.LIB(MSVCRTD.dll) : error LNK2005: _memmove already defined in LIBCMTD.LIB(memmove.obj)


但是仔细查看了所用的链接库又都没有问题,没办法,只好一个库一个库的找,后来发现原来是MSVCRTD.LIB LIBCMTD.LIB 这两个库的先后顺序导致的问题,正确的顺序应该是


MSVCRTD.LIB LIBCMTD.LIB 而不是 LIBCMTD.LIB MSVCRTD.LIB


不知道什么原因???


 

This entry was posted in [P]编程技术. Bookmark the permalink.

5 Responses to 【编程】编程语言(C++) – 编译 – MSVCRTD.LIB LIBCMTD.LIB 的顺序导致的编译错误!

  1. 真命天子 says:

    这个问题很简单,就是在自己写的那个类的成员函数实现的时候,某个对象是全局定义,而在其他的相关连接的文件中,又定义了它。所以把那个对象在成员函数实现的时候定义成局部对象,就OK了

  2. leafsilver says:

    调整lib的加载顺序即可

  3. bluez says:

    我想问题的主要原因还是,各个Lib模块中的编译选项不一致导致的

  4. 匿名 says:

    谢谢!

  5. maxint says:

    先忽略了这两个库,再按顺序添加,怎么还是不行?不知这两个库做什么用的,Console程序可以直接忽略MSVCRTD就能解决这个问题,但是MFC程序一忽略问题反而更多了

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word