wes*_*wes 11 c++ winapi qt visual-studio-2010 static-linking
我正在尝试使用Visual Studio 2010中的MTd而不是MDd进行编译(因此dll是打包的,我不需要用我的exe分发它们),但我不断得到"致命错误LNK1169:一个或多个乘法在编译期间找到的已定义符号.MDD编译正常但在其他计算机上没有MSVCP100.dll时无法正常工作.
我正在使用Qt的静态构建,我正在尝试构建VS加载项附带的默认Qt程序.
是否有另一种强制链接器静态编译的方法?我所要做的就是将Qt程序作为exe发布而不用dll.
这是构建日志:
1>ClCompile:
1> All outputs are up-to-date.
1> cooltest1.cpp
1> moc_cooltest1.cpp
1> main.cpp
1> Generating Code...
1> All outputs are up-to-date.
1> qrc_cooltest1.cpp
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMT.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in LIBCMT.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMT.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMT.lib(memmove.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strncmp already defined in LIBCMT.lib(strncmp.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _isupper already defined in LIBCMT.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _isalpha already defined in LIBCMT.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _isdigit already defined in LIBCMT.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _isspace already defined in LIBCMT.lib(_ctype.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __control87 already defined in LIBCMT.lib(_ieee87_.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __clearfp already defined in LIBCMT.lib(_ieee87_.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strncpy_s already defined in LIBCMT.lib(strncpy_s.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strcpy_s already defined in LIBCMT.lib(strcpy_s.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _realloc already defined in LIBCMT.lib(realloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &,int)" (??0exception@std@@QAE@ABQBDH@Z) already defined in LIBCMT.lib(stdexcpt.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: __errno already defined in LIBCMT.lib(dosmap.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _abort already defined in LIBCMT.lib(abort.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>c:\users\username\documents\visual studio 2010\Projects\CoolTest1\\CoolTest1.exe : fatal error LNK1169: one or more multiply defined symbols found
1>
1>Build FAILED.
Run Code Online (Sandbox Code Playgroud)
Han*_*ant 14
修改/ MT时,这是标准的链接器错误.您现在链接一些使用/ MT编译的代码,因此依赖于libcmt.lib中的CRT代码,其中一些代码使用/ MD编译,因此依赖于msvcrt.lib中的CRT代码.这是不允许的,只有一个CRT链接到您的程序中.
您需要找到仍然使用/ MD编译的代码.此代码可能存在于.lib中,就像QT的运行时支持代码一样.如果QT没有支持静态链接CRT的.lib,那么你就会遇到/ MD.这并不罕见,编写存在于可以处理/ MT的DLL中的代码很困难.
Rai*_*aiv 10
您可以重建QT以使用静态VC库.转到${QtDir}\mkspecs\win32-msvc2010\qmake.conf
并替换
QMAKE_CFLAGS_RELEASE = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd
Run Code Online (Sandbox Code Playgroud)
同
QMAKE_CFLAGS_RELEASE = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MTd
Run Code Online (Sandbox Code Playgroud)
之后,干净的重新配置和重建qt
归档时间: |
|
查看次数: |
13722 次 |
最近记录: |