First, download the Qt SDK sources and the mysql server source version, extract both of them.
Create symlinks in mysql lib files:
sudo ln -s /Users/simon/Downloads/mysql-5.6.11-osx10.7-x86_64/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.dylib sudo ln -s /Users/simon/Downloads/mysql-5.6.11-osx10.7-x86_64/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient_r.dylib sudo ln -s /Users/simon/Downloads/mysql-5.6.11-osx10.7-x86_64/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib sudo ln -s /Users/simon/Downloads/mysql-5.6.11-osx10.7-x86_64/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient_r.18.dylib
After that, cd
to the extracted Qt SDK in the /Users/simon/Downloads/qt-everywhere-opensource-src-4.8.4/src/plugins/sqldrivers/mysql
folder
Build libraries:
qmake -spec macx-g++ -o Makefile "INCLUDEPATH+=/Users/simon/Downloads/mysql-5.6.11-osx10.7-x86_64/include" "LIBS+=-L/usr/lib -lmysqlclient_r" mysql.pro make mv libqsqlmysql_debug.dylib libqsqlmysql.dylib cp -R libqsqlmysql.dylib /Developer/Applications/Qt/plugins/sqldrivers/
After that, you can use the QMYSQL plugin. Check if the library with this line of code was loaded correctly (put it in some constructor so that you immediately after starting the application):
qDebug() << QCoreApplication::libraryPaths(); qDebug() << QSqlDatabase::drivers();
For example, my output is as follows:
("/Developer/Applications/Qt/plugins", "/Users/simon/Coding/qt4c/build-SQLtable-Desktop-Debug/SQLtable.app/Contents/MacOS") ("QSQLITE", "QMYSQL3", "QMYSQL", "QODBC3", "QODBC", "QPSQL7", "QPSQL")
source share