Visual C ++运行时库链接器故障 [英] Visual C++ Runtime Library Linker Woes
问题描述
即使看起来与我之前的问题相同,也请观察这种接近的情况.我仍然没有得到答案. 因此,请勿重复报告.
Observe this close Scenario even though it appears to be the same as my previous questions. Still I am not getting an answer. So please don't report as a duplicate.
我有一个有10个依赖项的项目.首先,我在主项目的C/C ++代码生成部分中使用/MTD选项进行了编译,并且其所有依赖项都已成功构建.
I have a project which has 10 dependencies. First I compiled using the /MTD option in the C/C++ codegeneration section in the main project and all its dependencies are getting build successfully.
接下来,我将选项从/MTD更改为/MDd,并且所有相关项目都在获取 建立成功.但是对于主要项目,报告了以下错误:
Next I changed the option from /MTD to /MDd and again all dependent projects are getting build successfully. But for the main project the following errors are reported:
LIBCMTD.lib(osfinfo.obj) : error LNK2005: __open_osfhandle already defined in MSVCRTD.lib(MSVCR80D.dll)
LIBCMTD.lib(lseeki64.obj) : error LNK2005: __lseeki64 already defined in MSVCRTD.lib(MSVCR80D.dll)
sqlite3x.lib(sqlite3x_command.obj) : error LNK2005: "protected: wchar_t * __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::_Myptr(void)" (?_Myptr@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEPA_WXZ) already defined in msvcprtd.lib(MSVCP80D.dll)
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __mkdir already defined in LIBCMTD.lib(mkdir.obj)
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __strdup already defined in
LIBCMTD.lib(strdup.obj)
Creating library Debug/Application.lib and object Debug/Application.exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
我该如何解决?
推荐答案
您不能混合使用C运行时库.如果您有一个库或对象编译为/MT(任何东西),则不能仅与/MD链接.您需要与线程安全MSVCRT链接.根本没有if和and或but.您不能混合使用C运行时.即使在不执行线程的程序中,我也总是发现最好只使用/MT.
You cannot mix C runtime libraries. If you have a library or object compiled /MT(anything), you cannot just link with /MD. You need to link with the threadsafe MSVCRT. There's no if's and's or but's about it. You CANNOT mix C runtimes. I've always found it best, even in programs that don't do threading, to just use /MT.
您是否执行了项目清除操作以删除已构建的对象和库?您在这里也依赖于SQLite,是否也重新构建了它?
Did you run a project clean operation to remove already built objects and libraries? You have a dependency on SQLite here as well, did you rebuild that, too?
这篇关于Visual C ++运行时库链接器故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!