QSqlDatabase:没有加载到Mac OS上的QMYSQL驱动程序

时间:2021-01-10 22:57:29

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

我已经在Windows和一些Linux版本上解决了这个问题,现在是Mac时间。这一切从以下几点开始:

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

Mac上Qt的MySQL

QSqlDatabase: QMYSQL driver not loaded on Xubuntu 16.04 64bits

QSqlDatabase: QMYSQL驱动程序没有加载到Xubuntu 16.04 64位

QSqlDatabase: QMYSQL driver not loaded on Ubuntu 15.04 64bits

QSqlDatabase: QMYSQL驱动程序没有加载到Ubuntu 15.04 64位

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

我只是这么做了,问题是新的lib(在~Qt/5.7/Src/qtbase/plugins/sqldrivers中找到),就是刚刚编译的那个

~/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.

具有与旧版本相同的大小(参见~Qt/5.7/clang_64/plugins/sqldrivers)。我是说,刚才编译的库和已经编译好的库是一样的。我仍然没有加载QSqlDatabase: QMYSQL驱动程序。

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.

我对此有一些了解,但我会让更多的人了解这个领域的细节。

1 个解决方案

#1


0  

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/

#1


0  

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/