[Qt-interest] "cannot find -lqsqlodbc" error while compiling the qt application statically....

Mark Brand mabrand at mabrand.nl
Mon May 16 22:23:52 CEST 2011


Hi Mammaiap,

> i am compiling my application statically....i have followed the below 
> mentioned steps to do the static linking...
>
> http://www.formortals.com/how-to-statically-link-qt-4/
>

Those instructions are somewhat outdated.

> i slightly modified the *.pro file and get the only one error...
>
> "collect2:ld returned 1 exit status"...
>
> and below is the compile output in "Qt Creator"...
>
> ./obj\main.o:main.cpp:(.text+0x9): undefined reference to 
> `qt_plugin_instance_qsqlodbc()'


As I mentioned in my first reply, when you configure Qt with "-static", 
SQL drivers are by default not built as plugins. In this case the driver 
is part of the QtSql library and should just work.

Unless you explicitly configured the odbc driver to be a plugin, remove 
"QTPLUGINS += libqsqlodbc" from your testproject.pro file and 
"Q_IMPORT_PLUGIN(qsqlodbc)" from main.cpp.

By the way, the mingw-cross-env project has good support for static Qt. 
Even if you are not interested in cross-compiling, it might be helpful 
to look at the configuration there.

regards,

Mark




More information about the Qt-interest-old mailing list