[Qt-interest] "cannot find -lqsqlodbc" error while compiling the qt application statically....
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Tue May 17 11:12:37 CEST 2011
Hi Mammaiap,
Did you look at the source of the Qt odbc driver itself? It's in
src/sql/drivers/odbc. You might then realise that the missing routines are
the interfaces to MS ODBC itself. So you need to include the .lib for ODBC
in your LIBS. The file qsql_odbc.pri shows you how.
As previously mentioned, libqsqlodbc should already be present in QtSql -
I'm surprised you're not getting duplicate symbol errors as well!
Even when you get the link to work, I'm pretty sure your target environment
will still need to have ODBC installed - which it will for Windows, but not
necessarily on *nix.
Hope that helps,
Tony
-----Original Message-----
Sent: Tuesday, 17 May 2011 18:45 PM
Hi Mark,
Thanks for your reply...
i build the odbc driver plugin statically when building Qt... after the
static building it generates the "libqsqlodbc.a" file with the size of 146KB
in the "C:\Qt-4.7.0-Static\2010.05\qt\plugins\sqldrivers" directory...
is it OK? or is there any other files need to be generated along with
"libqsqlodbc.a" file?
after that i slightly modified the *.pro and main.cpp ... please see the
attachments...
and now i got only one error : "collect2:ld returned 1 exit status"
and attached see the below compiler output ........
please help me to fix this problem..
Thanks,
mammaiap
On Tue, May 17, 2011 at 1:53 AM, Mark Brand <mabrand at mabrand.nl> wrote:
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110517/b209e7ed/attachment.html
More information about the Qt-interest-old
mailing list