Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 319
Vincent Duprez Avatar asked Dec 28 '25 18:12

Vincent Duprez


1 Answers

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.

like image 93
ce_nort Avatar answered Dec 31 '25 09:12

ce_nort



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!