Visual Studio - error LNK2005 in debug mode

瘦欲@ 提交于 2019-12-04 07:51:28

For some reason, you're linking against both LIBCMT and LIBCMTD (the debug version). (From reading the end of each error line: already defined in libcmtd.lib(invarg.obj))

You're fixing the right thing by saying /NODEFAULTLIB:LIBCMT. Does the debug/release flag on the third-party library that you're linking against match the debug/release mode on your app build? I would guess that the third-party code is pulling in a redundant library somehow.

If you're lucky, your 3rd party package contains a xxx.lib as well as a xxxD.lib, like for LIBCMT. Then you would just have to link the appropriate one according to release/debug. Worked for me in a similar case.

I resolved the same problem this way: In the Solution Explorer > Configuration Parameters > C/C++ > Code Generation. In the Runtime Library field, select.... for my "3rd party code" I had to select Multi-threaded (/MTd) and it worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!