[CMake] Link error when building static exe against static Qt 4.5 plugin

Andreas Pakulat apaku at gmx.de
Mon Mar 23 05:10:38 EDT 2009


On 23.03.09 08:16:35, Stephen Collyer wrote:
> I'm trying to build a fully static exe on Opensuse 11.1 against a static
> build of Qt 4.5, and
> I'm trying to link against a static QMySQL plugin.
> 
> I'm getting a link error when I do so, and I suspect it's because I'm not
> telling LINK_LIBRARIES how
> to link against the static plugin.
> 
> /usr/bin/c++   -O3 -DNDEBUG  -fPIC
> CMakeFiles/file_transfer_scheduler_exe.dir/file_transfer_scheduler.o  -o
> file_transfer_scheduler_exe -rdynamic
> -L/usr/local/Trolltech/Qt-4.5.0-static/lib ../lib/libFileTransferScheduler.a
> ../lib/libSSHPrivateKey.a ../lib/libIPCListener.a ../lib/libComms.a
> ../lib/libExceptions.a ../lib/libSupport.a
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtGui.a -lpng -lSM -lICE
> -lXrender -lfreetype -lfontconfig -lXext -lX11 -lm
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtXml.a
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtSql.a
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtNetwork.a -lssl
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtCore.a -lz -lgthread-2.0
> -lglib-2.0 -lrt -lpthread -ldl ../lib/libClientCertificate.a
> ../lib/libServer.a ../lib/libUIObject.a ../lib/libTimedMessages.a
> ../lib/libTransferrers.a ../plugins/libcurlPlugin.a ../lib/libHTTP.a -lcurl
> ../lib/libCommonProperties.a ../lib/libRunnable.a ../lib/libComms.a
> ../lib/libPersistence.a ../lib/libRunQuery.a ../lib/libSupport.a
> ../lib/libLogger.a ../lib/libExceptions.a ../lib/libAgentSettings.a
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtGui.a -lpng -lSM -lICE
> -lXrender -lfreetype -lfontconfig -lXext -lX11 -lm
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtXml.a
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtSql.a
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtNetwork.a -lssl
> /usr/local/Trolltech/Qt-4.5.0-static/lib/libQtCore.a -lz -lgthread-2.0
> -lglib-2.0 -lrt -lpthread -ldl
> -Wl,-rpath,/usr/local/Trolltech/Qt-4.5.0-static/lib
> CMakeFiles/file_transfer_scheduler_exe.dir/file_transfer_scheduler.o: In
> function `global constructors keyed to
> _Z15log_start_statetRK7QStringS1_S1_S1_':
> file_transfer_scheduler.cpp:(.text+0x91): undefined reference to
> `qt_plugin_instance_qsqlmysql()'
> 
> Can anyone suggest what I'm screwing up here ? I'm guessing that I need to
> do something different
> than merely link against ${QT_LIBRARIES} but I'm not sure what.

Are you sure yout Qt4.5 has the mysql plugin built in? There's only two
cases for the plugins (AFAIK):

a) real plugins as shared objects in the plugins dir
b) built directly into the static Qt libs

So obviously in case a) you don't need to link against the mysql-plugin,
because Qt will load it itself during runtime and in the second case it
should be part of the QtSql library.

Can you show the relevant cpp file and cmake code?
 
Andreas

-- 
You are fighting for survival in your own sweet and gentle way.


More information about the CMake mailing list