[英]Qt + VS2010 compiler: How to create a simple project that would use compiled for VC staticaly linked boost?
How to create a simple project that would use compiled for VC staticaly linked boost (that is somewhhere like C:/boost)? 如何创建一个简单的项目,该项目将使用已编译的VC静态链接提升功能(类似于C:/ boost)? How shall my project file look like?
我的项目文件应如何显示?
I tried to add to .pro 我试图添加到.pro
INCLUDEPATH += C:/BOOST/include/boost-1_49
DEPENDPATH += C:/BOOST/lib
LIBS += -LC:/BOOST/lib -llibboost_system-vc100-mt-sgd-1_49 -llibboost_thread-vc100-mt-sgd-1_49
but I get: 但我得到:
msvcprtd.lib(MSVCP100D.dll):-1: ERROR: LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in libboost_system-vc100-mt-sgd-1_49.lib(error_code.obj)
msvcprtd.lib(MSVCP100D.dll):-1: ERROR: LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in libboost_system-vc100-mt-sgd-1_49.lib(error_code.obj)
msvcprtd.lib(MSVCP100D.dll):-1: ERROR: LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in libboost_system-vc100-mt-sgd-1_49.lib(error_code.obj)
:-1: WARNING: LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
debug\loader.exe:-1: ERROR: LNK1169: one or more multiply defined symbols found
when I try to compile something like: 当我尝试编译类似:
#include <QtGui/QApplication>
#include <iostream>
#include <boost/filesystem.hpp>
int main(int argc, char *argv[])
{
boost::filesystem::path p;
}
So I wonder how shall I change my .proo file to link correctly to static boost compiled for VC using Qt Creator that is using VS compiler? 因此,我想知道如何更改.proo文件以正确链接到使用VS编译器的Qt Creator进行VC编译的静态boost?
If you built boost with the --runtime-link=static
flag then they were compiled against the static CRT libraries, ie using the /MT
(and /MTd
for debug) compiler flags. 如果使用
--runtime-link=static
标志构建了boost,那么它们将针对静态CRT库进行编译,即使用/MT
(和/MTd
用于调试)编译器标志。
Your errors suggest your project is trying to link with the dynamic CRT lib, ie using /MD
and /MDd
. 您的错误表明您的项目正在尝试与动态CRT库链接,即使用
/MD
和/MDd
。 If these are set in your .pro file, they will be a part of the QMAKE_CXXFLAGS_RELEASE
and QMAKE_CXXFLAGS_DEBUG
variables. 如果在您的.pro文件中设置了它们,它们将成为
QMAKE_CXXFLAGS_RELEASE
和QMAKE_CXXFLAGS_DEBUG
变量的一部分。 They might however not be listed at all - I think the default is to use the dynamic CRT lib. 但是,它们可能根本没有列出-我认为默认设置是使用动态CRT库。
All the libraries in your project need to link against the same CRT. 项目中的所有库都需要链接到同一CRT。
You either need to use --runtime-link=shared
when building boost (you can still use --link=static
to create static boost libs with this option though), or add/change the /MD
and /MDd
to /MT
and /MTd
in your .pro file. 在构建boost时,您需要使用
--runtime-link=shared
(尽管仍然可以使用--link=static
来通过此选项创建静态boost库),或者将/MD
和/MDd
添加/更改为/MT
和.pro文件中的/MTd
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.