Static Qt with static MSVC C++ library
Hi,
I am compiling an application statically with no problem but I would like to use the static version of the MSVC C++ library. To do so I use:
QMAKE_CFLAGS_RELEASE += /MT
QMAKE_CXXFLAGS_RELEASE += /MT
But I get multiple definitions of the same symbol:
…
MSVCRT.lib(MSVCR100.dll) : error LNK2005: __open_osfhandle already defined in LIBCMT.lib(osfinfo.obj)
Is there an easy solution or should I tell the linker to accept multiple symbols?
10 replies
Since you are refering to MSVC C++ I would assume that you are also using visual studio. You could install vsaddin [developer.qt.nokia.com]
There is no need to use qmake explicitely.
I have just compiled a small project with /MT option. I was compiling with dlls before.
First recompilation it complaint that I need to specify /NODEFAULTIB
Second recompilation gave loads of error messages. Probable I would need to adjust more settings, which I can’t do today.
BTW: I am using Win 7 64 bit and msvc2005.
It looks like with MSVC you need to tell at compile-time DLL or LIB dependencies. This means you need to rebuild QT to use static VC libraries. Go to ${QtDir}\mkspecs\win32-msvc2010\qmake.conf, and replace
QMAKE_CFLAGS_RELEASE = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd
with
QMAKE_CFLAGS_RELEASE = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MTd
Just for the records I found a nmake clone that uses all the available cores on the system… just like “-jX” of make:
http://labs.qt.nokia.com/2009/03/27/speeding-up-visual-c-qt-builds/
Just for the records I found a nmake clone that uses all the available cores on the system… just like “-jX” of make: http://labs.qt.nokia.com/2009/03/27/speeding-up-visual-c-qt-builds/
Yes, jom may reduce your overall compilation time cosiderably.
MSVCRT.lib(MSVCR100.dll) : error LNK2005: __open_osfhandle already defined in LIBCMT.lib(osfinfo.obj)Is there an easy solution or should I tell the linker to accept multiple symbols?
As answer to your initial question: You may also exclude LIBCMT (option: NODEFAULTLIB:LIBCMT). This is eliminating the multiple definitions warning/error.
However, for msvc2005 there is an error:
- error LNK2019: unresolved external symbol _WSAAsyncSelect@16 referenced in function "public: void __thiscall EventDispatcherWin32Private::doWsaAsyncSelect(int)" (?doWsaAsyncSelect@QEventDispatcherWin32Private@@QAEXH@Z)
This error is there also when LIBCMT has not been ignored, respectively, also accepting multiple definitions does not help. Could be an msvc2005 specific problem.
You must log in to post a reply. Not a member yet? Register here!


