我正在开发使用Qt 4.8.3和VS2008的本机C++应用程序。由于客户在裸机上运行应用程序,他们需要安装VC++ 2008 Redistribution包。所以我决定让它静态链接。使用Qt静态构建库链接错误
我将项目设置(C/C++>代码生成>运行时库)更改为/ MTd。也是 我再次编译Qt,这次使用以下命令建立静态建筑;最初发现在这个博客Static Qt with static CRT (VS 2008)
1- replaced -MD with -MT in lines QMAKE_CFLAGS_RELEASE and QMAKE_CFLAGS_DEBUG in %QDIR%\mkspecs\win32-msvc2008\qmake.conf
2- nmake confclean
3- configure -static -platform win32-msvc2008 -no-webkit
4- nmake sub-src
我编译Qt成功。但是当我再次尝试编译我的应用程序时,它给了我一些奇怪的错误。
1>Linking...
1>qtmaind.lib(qtmain_win.obj) : error LNK2005: "public: bool __thiscall QBasicAtomicInt::deref(void)" ([email protected]@@QAE_NXZ) already defined in QtCored4.lib(QtCored4.dll)
1>qtmaind.lib(qtmain_win.obj) : error LNK2005: "public: bool __thiscall QBasicAtomicInt::operator!=(int)const " ([email protected]@[email protected]) already defined in QtCored4.lib(QtCored4.dll)
1>qtmaind.lib(qtmain_win.obj) : error LNK2005: "public: __thiscall QString::~QString(void)" ([email protected]@[email protected]) already defined in QtCored4.lib(QtCored4.dll)
我改变了一些lib文件,但随着每次更改,情况变得更糟;例如我试图使用QtCored.lib而不是QtCored4.lib,因为它是在编译后新创建的。
我想我已经错过了建立静态Qt库的东西。