简体   繁体   中英

QSqlDatabase: QMYSQL driver not loaded on Mac OS

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 ie:

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM