[Solved] New Qt install and MySql
I need some help getting MySQL running with my Qt server application. There are lots of other posts/search results for this, but I have what may be basic questions that never seem to be answered.
Qt 5.4 (open source/community) installed from website to /home/matt/Qt
MySql Server 5.5 installed from repo
I'm trying to build a client/server application. While developing, the client, server and mysql server will all run on the same machine. When deployed all 3 can and will be running on different machines (client on Windows, server and mysql server on Linux).
According to "this page":http://doc.qt.io/qt-5/sql-driver.html#qmysql: Qt comes packaged with a driver for mysql and there is a file called libsqlmysql.so in this location:
But the page also says 'not all of the plugins are provided with Open Source Versions of Qt'. So which drivers aren't? I've tried to connect to my mysql database but get the following error:
@QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7@
using this code:
@ QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
Do I need to build the driver for mysql for my setup?
What are the actual requirements for getting this to work with my development setup (i.e. 1 machine) and later on with the server app and database server running on different machines?
Hi and welcome to devnet,
Do you have the MySQL client libraries installed on your machine ?
Hi SGAist, thanks for your reply. I'm not sure if the client libraries are installed - what are they?
I have mysql-client and mysql-server installed, and apt-get offers these other options for mysql*:
Ok, then run ldd on the plugin to check if everything it needs can be found
Do you mean this file:
If so, this is the ldd output:
@linux-vdso.so.1 => (0x00007fff6bda5000)
libmysqlclient_r.so.16 => not found
libQt5Sql.so.5 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fd0a85db000)
libQt5Core.so.5 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fd0a7e9e000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd0a7b9a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd0a77d2000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd0a75b4000)
libicui18n.so.53 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.53 (0x00007fd0a7168000)
libicuuc.so.53 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.53 (0x00007fd0a6ddd000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd0a6bd8000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fd0a69d6000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd0a67ce000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fd0a64cc000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd0a61c8000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd0a5fb2000)
libicudata.so.53 => /home/matt/Qt/5.4/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.53 (0x00007fd0a4929000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fd0a46ea000)@
I'm guessing this is the problem?
@libmysqlclient_r.so.16 => not found@
But I have no idea why, or how to fix it!
You probably have libmysqlclient_r.so.16 on your system so you can either try to get version 16 installed or rebuild the plugin to use your currently installed library version
OK, thanks. In this context are 'plugin' and 'driver' the same thing? In both cases is it this file:
And this file plugin/driver (that came with my install of Qt) has been built with version 16?
I will try to build it using the instructions "here":http://qt-project.org/doc/qt-4.8/sql-driver.html#qmysql
Thanks SGaist, that got it working - it turned out I had version 18.
One thing I didn't find too clear in the instructions was what the 'INCLUDEPATH' should be so left it as:
It seemed to work even though there is nothing in that folder on my system.
How does Qt/my application know where to look for the driver? When I move the server application to a new system where should the driver go?
That's because you have a distribution installed MySQL which put dev package content in common places.
It's built in the library, if you take a look at the folder structure of Qt you'll see how it works..
How do you plan to distribute your application ??