[Qt-interest] QMYSQLDriver - linking plugin's dynamic library
Piotr Dąbrowski
ultr at ultr.pl
Thu Aug 11 12:52:13 CEST 2011
Hello,
I'm trying to use QSqlDatabase::addDatabase() to access an
already-open MySQL connection:
http://doc.qt.nokia.com/latest/qsqldatabase.html#addDatabase-2
Documentation says it is recommended to include driver's source file,
which I don't want. It requires choosing a single version of Qt and
may be acceptable for binary applications, but not for source
distribution.
I tried including only the header file (QtSql/qsql_mysql.h) and
linking the binary against plugins/sqldrivers/libqsqlmysql.so library
(cmake):
[...]
find_library (QT_QSQLMYSQL_LIBRARY qsqlmysql)
if (QT_QSQLMYSQL_LIBRARY)
message (STATUS "Found QMYSQLDriver library: ${QT_QSQLMYSQL_LIBRARY}")
else (QT_QSQLMYSQL_LIBRARY)
message (FATAL_ERROR "Could not find QMYSQLDriver library")
endif (QT_QSQLMYSQL_LIBRARY)
target_link_libraries (sql_history ${QT_QTSQL_LIBRARIES}
${MYSQL_LIBRARIES} ${QT_QSQLMYSQL_LIBRARY})
but I still get linking error:
symbol lookup error: /.../libsql_history.so: undefined symbol:
_ZN12QMYSQLDriverC1EP8st_mysqlP7QObject
Adding
#include <QtPlugin>
Q_IMPORT_PLUGIN(qsqlmysql)
results in another error:
undefined symbol: _Z28qt_plugin_instance_qsqlmysqlv
Am I doing something wrong?
How should this be done?
More information about the Qt-interest-old
mailing list