[Qt-creator] Static build with Microsoft compiler
Charles N Burns
charlesnburns at gmail.com
Mon Nov 23 00:06:15 CET 2009
Hello all,
I am trying to use Qt Creator 1.3 RC to make a static build of an
application using the Microsoft compiler (from Visual Studio Prof.
2008).
I am familiar with building Qt static (and have even written some
articles on how to do so), but when I try to build my application in
Qt Creator, it builds with dynamic linking, even when I specify a
statically compiled version of Qt. I wasn't aware this was even
possible.
I know the resulting executable is dynamic because it is very small
and, when I run it directly, it complains about missing qtcore.dll.
---------------------- .pro file --------------------------
TARGET = ImageGuide
TEMPLATE = app
SOURCES += main.cpp Window.cpp mediancut.cpp
HEADERS += Window.h mediancut.h ScrollArea.h
CONFIG += static staticlibs stl
static {
QTPLUGIN += qjpeg qgif qtiff
DEFINES += STATIC
}
---------------------- from main.cpp file --------------------------
In my main.cpp:
#ifdef STATIC
#include <QtPlugin>
Q_IMPORT_PLUGIN(qjpeg)
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qtiff)
#endif
-------------------------- --------------------------
The linker errors I get start with:
C:/qtprojects/ImageGuideMC/main.obj:-1: error: unresolved external
symbol "class QObject * __cdecl qt_plugin_instance_qjpeg(void)"
(?qt_plugin_instance_qjpeg@@YAPAVQObject@@XZ) referenced in function
"public: __thiscall
StaticqjpegPluginInstance::StaticqjpegPluginInstance(void)"
(??0StaticqjpegPluginInstance@@QAE at XZ)
When I remove the Q_IMPORT_PLUGIN statements, my project compiles just
fine, but it is NOT statically linked.
How can I build a statically linked program using the MS compiler?
Best regards,
--Charles Burns
http://www.formortals.com/author/charles
More information about the Qt-creator-old
mailing list