链接错误试图链接的刺激时,文件系统::调试MSVC11项目 [英] Linker errors when attempting to link boost::filesystem to debug MSVC11 project
问题描述
我试图在我的项目中使用的boost ::文件系统
,但我碰到的链接错误:
I'm attempting to use boost::filesystem
in my project, but I've run into linker errors:
Error 14 error LNK1169: one or more multiply defined symbols found C:\Users\Developer\Desktop\mandala3d\Debug\mandala.exe 1 1 mandala
Error 5 error LNK2005: "public: __thiscall std::bad_cast::bad_cast(char const *)" (??0bad_cast@std@@QAE@PBD@Z) already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(stdexcpt.obj) mandala
Error 4 error LNK2005: "public: __thiscall std::bad_cast::bad_cast(class std::bad_cast const &)" (??0bad_cast@std@@QAE@ABV01@@Z) already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(stdexcpt.obj) mandala
Error 12 error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMT.lib(stdexcpt.obj) C:\Users\Developer\Desktop\mandala3d\mandala\MSVCRTD.lib(MSVCR110D.dll) mandala
Error 6 error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(stdexcpt.obj) mandala
Error 7 error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(stdexcpt.obj) mandala
Error 8 error LNK2005: "public: virtual __thiscall std::bad_cast::~bad_cast(void)" (??1bad_cast@std@@UAE@XZ) already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(stdexcpt.obj) mandala
Error 9 error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(stdexcpt.obj) mandala
Error 13 error LNK2005: "public: virtual char const * __thiscall std::exception::what(void)const " (?what@exception@std@@UBEPBDXZ) already defined in LIBCMT.lib(stdexcpt.obj) C:\Users\Developer\Desktop\mandala3d\mandala\MSVCRTD.lib(MSVCR110D.dll) mandala
Error 10 error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(invarg.obj) mandala
Error 11 error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR110D.dll) C:\Users\Developer\Desktop\mandala3d\mandala\LIBCMT.lib(invarg.obj) mandala
我建设提升用下面的命令:
I am building boost with the following commands:
bootstrap
.\b2
和我指着 $ BOOSTDIR \\阶段\\ lib中
的库包括目录,我的编译器是的Visual Studio 2012(V110)
。
And I am pointing to $BOOSTDIR\stage\lib
for the library include directory and my compiler is Visual Studio 2012 (v110)
.
我直接尝试连接的调试
是在 $ BOOSTDIR \\产生的lib \\ *
目录库,但跑进其他错误。我还怀疑是不是静态链接库的标准或预期的方式。
I have tried directly linking the debug
libraries that are generated in the $BOOSTDIR\lib\*
directories but ran into other errors. I also suspect that that is not the standard or intended way to statically link the libraries.
我在做什么错在这里?
推荐答案
您正在混合使用C运行时库的联系和调试/释放二进制文件。
You're mixing both C runtime library linkages and debug/release binaries.
libcmt
是静态C运行时库的发行版本,而 msvcrtd
是动态的调试版本C运行时库。您同时显示在你的错误,这意味着你要他们混,你不能做。
libcmt
is the release version of the static C runtime library, while msvcrtd
is the debug version of the dynamic C runtime library. You have both showing up in your errors, meaning that you're trying to mix them, which you can't do.
您需要重建加速使用C运行时的相同版本的项目或重建项目中使用相同版本的加速。然而,事实上,你目前拥有的调试和发行库混合通常是一个标志,别的东西是真的错了您的设置。
You need to rebuild Boost to use the same version of the C runtime as your project, or rebuild your project to use the same version as Boost. However, the fact that you currently have debug and release libraries mixed is usually a sign that something else is really wrong with your settings.
如果您在项目中的属性看,转到C / C ++ - > code一代,你会看到一个运行时库字段。您可以将其更改为指定项目应该如何链接到C运行时。 / MDD将链接 msvcrtd.dll
,而/ MT将链接 LIBCMT.LIB
。
If you look in your project's properties and go to C/C++ -> Code Generation, you'll see a 'Runtime Library' field. You can change this to specify how your project should link to the C runtime. /MDd will link msvcrtd.dll
, while /MT will link libcmt.lib
.
这篇关于链接错误试图链接的刺激时,文件系统::调试MSVC11项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!