2

I've already solved this problem on Windows and some Linux flavors, now is Mac time. It all starts with the following:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

Then the solution should be more or less what is pointed in the following links i.e.:

MySQL for Qt on Mac

QSqlDatabase: QMYSQL driver not loaded on Xubuntu 16.04 64bits

QSqlDatabase: QMYSQL driver not loaded on Ubuntu 15.04 64bits

In the end a new version of (debug and release) the lib should be produced, then is a matter of replacing the old one by the new one and everything will work from now on.

I just did that and the problem is that the new lib (found in ~Qt/5.7/Src/qtbase/plugins/sqldrivers), the one just compiled with

~/Qt/5.7/clang_64/bin/qmake "INCLUDEPATH += /usr/local/mysql-5.6.17-osx10.7-x86_64/include/" "LIBS += -L/usr/local/mysql-5.6.17-osx10.7-x86_64/lib/"
make

have the same size as the older (found in ~Qt/5.7/clang_64/plugins/sqldrivers). I mean, the lib just compiled is the same as the one already there. And I still get the QSqlDatabase: QMYSQL driver not loaded.

Can some one please put some light here? What's going on?

After some time I found (here) that

install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlmysql_debug.dylib

and

install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/Qt/5.7/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

helps.

I have some understanding of this but I'll leave it open to someone more knowledgeable in the field to give the details.

Community
  • 1
  • 1
KcFnMi
  • 5,516
  • 10
  • 62
  • 136

1 Answers1

1

The critical part is to:

~/Qt/5.8/clang_64/bin/qmake "INCLUDEPATH += /usr/local/mysql-5.6.17-osx10.7-x86_64/include/" "LIBS += -L/usr/local/mysql-5.6.17-osx10.7-x86_64/lib/" mysql.pro

make

And then:

cp ~/Qt/5.8/Src/qtbase/plugins/sqldrivers/ ~/Qt/5.8/clang_64/plugins/sqldrivers/
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • 1
    3 weeks getting the same error message. Installing mysql c connector and compiling qt multiple times The only step left was the cp command – angel Apr 15 '23 at 08:43