Linking error while using Qt static built libraries
Posted
by
Kamran Amini
on Stack Overflow
See other posts from Stack Overflow
or by Kamran Amini
Published on 2012-12-08T22:24:38Z
Indexed on
2012/12/08
23:03 UTC
Read the original article
Hit count: 357
I hope this is not a duplicate.
Recently I'm developing a native C++ application using Qt 4.8.3 and VS2008. Since clients run the application on their naked machines, they need to install VC++ 2008 Redistribution package. So I decided to make it statically linked.
I changed my project settings (C/C++ > Code Generation > Runtime Library) to /MTd. Also I compiled Qt again, this time using following commands for a static building; originally found on this blog 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
I compiled Qt successfully. But when I tried again to compile my application, it gave me some strange errors.
1>Linking...
1>qtmaind.lib(qtmain_win.obj) : error LNK2005: "public: bool __thiscall QBasicAtomicInt::deref(void)" (?deref@QBasicAtomicInt@@QAE_NXZ) already defined in QtCored4.lib(QtCored4.dll)
1>qtmaind.lib(qtmain_win.obj) : error LNK2005: "public: bool __thiscall QBasicAtomicInt::operator!=(int)const " (??9QBasicAtomicInt@@QBE_NH@Z) already defined in QtCored4.lib(QtCored4.dll)
1>qtmaind.lib(qtmain_win.obj) : error LNK2005: "public: __thiscall QString::~QString(void)" (??1QString@@QAE@XZ) already defined in QtCored4.lib(QtCored4.dll)
I changed some lib files but with each change, situation got worse; for example I tried to use QtCored.lib instead of QtCored4.lib because it is newly created after compilation.
I think I've missed something in building static Qt libs.
Thanks.
© Stack Overflow or respective owner