PDA

View Full Version : MYSQL Driver Not Loaded QT5.7 CentOS 7



fsh
19th December 2016, 20:43
I have installed mariaDB on CentOS 7 and am trying to build and run with MySQL using QT 5.7.
Having done my best to follow all documentation I could find and all of the other threads I have been able to understand on this issue, I am still coming up with "Driver Not Loaded" when I execute.

I'm using the LGPL version of Qt 5.7.

I tried the following:
I have /usr/lib64/libmysqlclient.so.18.0.0 with libmsyqlclient.so.18, libmysqlclient_r.so.18, and libmysqlclient.so all symbolically linked to it.
I tried in my makefile, LIBS += /usr/lib64/MySQL -lmysqlclient_r -lmysqlclient.
I compiled successfully, but when I ran, open() failed with the error "Driver not loaded."

Next I tried:
I have /opt/Qt/5.7/gcc_64/plugins/sqldrivers/libsqlmysql.so
I tried in my makefile, LIBS += -L/opt/Qt/5.7/gcc_64/plugins/sqldrivers/ -lsqlmysql.so.
I compiled with warnings that the libmysqlclient.so.16 was missing.

Following suggestions in some other threads, I symbolically linked libmysqlclient.so.16 and libsqlclient_r.so.16 to libmysqlclient.so and recompiled successfully.
But when I ran, open() still failed with the error "Driver not loaded"

What am I doing wrong? (And yes, I really have tried to find and understand the answer from the many other threads asking the similar question. :)

fsh
19th December 2016, 23:30
Ok, so I included both lib paths and suddenly it started working. Not sure why. I thought I tried that before unsuccessfully. NEVERMIND.

d_stranz
19th December 2016, 23:32
Have you put your Qt MySQL driver and your client library in an sqldrivers subdirectory of the directory that contains your executable? That is, you should have:

myprogram (exe)
sqldrivers/libmysqlclient.so
sqldrivers/libqsqlmysql.so

Have you run ldd libmysqlclient.so to make sure there are no other run-time dependencies? If the dependencies can't be found at runtime, you will get the "Driver not loaded" message.