简体   繁体   中英

Mysql Driver not loaded on Qt5.4 OS X Yosemite

I just did a fresh install of Yosemite on my mac. Installed Xcode, Qt5.4and mysql CE

I'm unable to make my app to work, I always get

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

I checked the dylib :

otool -L /Users/myself/Qt/5.4/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

and this returns me :

libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
    /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /Users/myself/Qt/5.3/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.3.0, current version 5.3.2)
    /Users/myself/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.2)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

I did not have the /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib file, in fact I do not event have the /opt folder on my Yosemite mac. Can this be?

I tried recreating the /opt/local/lib/mysql55/mysql/ folder myself and added the libmysqlclient.18.dylib in it but I still get the same issue.

I'm now completely clueless about how to resolve this, Am I doing something wrong? is this a Yosemite vs MySQL bug?

I think my .pro file and sources are ok as this used to work under my previous Mavericks config.

I know this is an old question, but I thought I'd share the solution I found (for those whose problem isn't solved by a fresh install).

Search your machine for libmysqlclient.18.dylib , and find where there is actually a copy of this file (mine was in /usr/local/Cellar/mysql56/5.6.32/lib/ ). Then use the install_name_tool command with the -change flag to point your libqmysql.dylib at it. Example of command use below:

install_name_tool -change /incorrect/path/to/libmysqlclient.18.dylib /correct/path/to/libmysqlclient.18.dylib /path/to/libqsqlmysql.dylib

Make sure to run the same command for the debug version, libqsqlmysql_debug.dylib so your debug builds are pointed to the correct lib as well.

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