Unsolved Qt5.12.0 QMYSQL plugin
-
I am new to QT and have been trying to connect to a mysql database using
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");Unfortunately Qt5.12.0 does not have this plugin loaded by default hence I kept getting the following errors
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7doing an ldd on the precompiled libqsqlmysql.so shows that it is trying to use libmysqlclient18 instead of the libmysqlclient20 that is the default sql client library on Ubuntu 16.04. Without any success, I've tried to rebuild the plugin with the following
'/home/dnovichman/Qt5.12.0/5.12.0/gcc_64/bin/qmake' "INCLUDEPATH+=-I/usr/include/mysql" "LIBS+=-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl" mysql.pro
undefined reference to `QSqlField::QSqlField(QString const&, QVariant::Type, QString const&)'Unfortunately, I'm getting a lot of undefined references like
undefined reference toQSqlResult::QSqlResult(QSqlResultPrivate&)' .obj/qsql_mysql.o:(.qtversion[qt_version_tag]+0x0): undefined reference to
qt_version_tag' -
Hi and welcome to devnet,
Where did you get the Qt sources from ?
-
I downloaded qt-unified-linux-x64-3.0.6-online.run from http://qt.mirrors.tds.net using this page https://www.qt.io/download-qt-installer?hsCtaTracking=9f6a2170-a938-42df-a8e2-a9f0b1d6cdce|6cb0de4f-9bb5-4778-ab02-bfb62735f3e5
-
The custom build logic has changed a bit. Are you following the guide ?
-
I've followed those instructions and rebuilt the entire QT by running the following commands from ~/Qt5.12.0/5.12.0/Src
./configure -sql-mysql
make installThat did still had the libqsmysql.so linking to libmysqlclient18 instead of libmysqlclient20.
Unfortunately, doing these additional commands
cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
make installLed to the current undefined reference compile issue
-
When calling
make install
, what was the folder used for the installation ? -
For ./configure -sql-mysql, make install was run in ~/Qt5.12.0/5.12.0/Src and for $QTDIR/qtbase/src/plugins/sqldrivers/mysql, make install was run in the $QTDIR/qtbase/src/plugins/sqldrivers/mysql
-
I meant the target folder.
-
Using MYSQL_PREFIX=/usr/include/mysql
and target is sub-mysql -
This post is deleted! -
This is meant to rebuild only the mysql plugin but ends up re-building all of Qt (with open source option)
-
I meant: what folder did you configure to have Qt installed to.
-
The default directory which I believe is ~/Qt5.12.0
-
Can you check that ?
Looking at the output of
make install
should show you exactly what is copied where. -
My Qt is installed in ~/Qt5.12.0. This has qt creator, qmake, gcc and android versions including the compiled libraries.
-
That I understood. Nevertheless, could you check as suggested the output of
make install
? -
The installation directory is /usr/local/Qt-5.12.0
-
Then that's where you custom built MySQL plugin can be found.
You likely have built it from a default configured Qt build hence that location.
-
@SGaist I tried doing a clean build today in ~/Qt5.12.0/5.12.0/Src with the following commands,
make clean
./configure -sql-mysql
make installI still ended up with the original errors regarding qt version and some functions not found.
Surprisingly, when I did
ldd /usr/local/Qt-5.12.0/plugins/sqldrivers/libqsqlmysql.soThere are no errors and it is linking to libmysqlclient.so.20 and using the qt that is in this location works flawlessly.
-
I recommend using out of source builds, so if something goes awry, you can nuke the build folder without having to look out for leftovers of previous builds.