Static build fails to include plugins, undefined symbols
-
I've built a static version of Qt for Mac, now I'm trying to build a statically linked application. I need graphics support, so I had planned on using Qt plugins (let me know if this isn't needed / correct) basedon things I had read online.
I've included <QtPlugin> and Q_IMPORT_PLUGIN statements in my code, and defined QPLUGIN in my .pro file. However, when the final executable is linked, I get the following errors:
@-L/usr/local/Trolltech/Qt-4.8.0/lib -framework Foundation -framework IOKit -framework AppKit -lQtTest -L/usr/local/Trolltech/Qt-4.8.0/lib -framework Security -framework ApplicationServices -framework CoreFoundation -lQtGui -framework Carbon -lQtCore -lz -lm
Undefined symbols for architecture x86_64:
"qt_plugin_instance_qgif()", referenced from:
global constructors keyed to mainin main.o
"qt_plugin_instance_qjpeg()", referenced from:
global constructors keyed to mainin main.o
"qt_plugin_instance_qico()", referenced from:
global constructors keyed to mainin main.o
"qt_plugin_instance_qsvg()", referenced from:
global constructors keyed to mainin main.o
"qt_plugin_instance_qtiff()", referenced from:
global constructors keyed to mainin main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status@/usr/local/Trolltech/Qt-4.8.0/ is the location of my static version of Qt.
My configure statement for Qt was:
@./configure -static -release -nomake examples -nomake demos -nomake tools -no-exceptions -stl -no-qt3support -no-script -no-scripttools -no-openssl -no-opengl -no-webkit -no-phonon -no-sql-sqlite -arch x86 -arch x86_64 -qt-libjpeg -qt-zlib -qt-libpng -qt-libtiff -qt-freetype -no-dbus -no-cups -no-declarative -no-declarative-debug -no-multimedia -no-accessibility -opensource@I'm not sure if I've excluded something important, or if I'm going about this all wrong.
-
I don't think anything in the GPL or LGPL prevents static linking when the software its is being linked with has a compatible license. My software is not commercial and will be released with the binary.
As for plugins, I was under the impression it was the opposite, that I needed to include the Qt Plugins for static linking.
An example of such instruction is here: "http://www.formortals.com/how-to-statically-link-qt-4/":http://www.formortals.com/how-to-statically-link-qt-4/So are plugins required to get image support in a statically linked application?
-
It's been some time since I have used a static Qt version (and only on Windows), but the problems seems to be that plugins/imageformats/*.lib are not included in your linker command (they should have been added by qmake with the QTPLUGIN command). Can you try manually add -L/usr/local/Trolltech/Qt-4.8.0/plugins/imagesformats and -lqjpeg4 etc. (or similar) to your LIBS specification?