QMYSQL : Driver not loaded
-
Im writing this after 2 hours of reading forum after forum with not straight cut answer. Can someone please tell me how to set up QMYSQL properly in order to communicate with a database. I have been using the standard default code provided my QT
--------( QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); ---------------
db.setHostName("");
db.setDatabaseName("Trainer");
db.setUserName("jefe");
--------------- db.setPassword("root");------------------------and keep getting the dreaded : QMYSQL Driver not loaded error... I'm using mac OS X
-
Could be issue with mysql drivers on your box. Try the instructions provided here.
http://jwintz.me/blog/2016/02/15/fixing-the-qt-mysql-driver-on-macosx-10-dot-11/ -
last command I put in was ''''' install_name_tool -change /usr/local/lib/libmysqlclient.18.dylib /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib libqsqlmysql.dylib '''' I did some research and this seems to be the correct way to be doing it in context of placing the driver i'm not sure whats going on now though from that command it should be working looking in /usr/local/Cellar/mysql/5.7.17 and running ls i have these files present
cd lib
192:lib trav$ ls
libmysqlclient.20.dylib libmysqld.a plugin
libmysqlclient.a libmysqlservices.a
libmysqlclient.dylib pkgconfigas well as running cd /usr/local/lib then ls I can see that ( see down) are present along with other ones i only included first 5 just for example
libexiv2.14.0.0.dylib
libexiv2.14.dylib
libexiv2.dylib
libmysqlclient.18.dylib
libmysqlclient.20.dylib -
Hi,
What does
otool -L libqsqlmysql.dylib
return ? -
@SGaist said in QMYSQL : Driver not loaded:
otool -L libqsqlmysql.dylib
Thank you for the reply!
trav$ otool -L libqsqlmysql.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: 'libqsqlmysql.dylib': No such file or directory.
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: internal objdump command failed -
otool -L /path/to/location/of/libqsqlmysql.dylib
-
trav$ otool -L /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib
/usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib:
/usr/local/opt/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0) -
I'm asking you to run otool on the Qt MySQL plugin. The path I've used in the command samples are meant to be replaced by the actual path to where the plugin is located. I don't know where it is on your system, so don't just copy paste the command, update it as well.
-
I'm asking you to run otool on the Qt MySQL plugin. The path I've used in the command samples are meant to be replaced by the actual path to where the plugin is located. I don't know where it is on your system, so don't just copy paste the command, update it as well.
@SGaist Sorry was 3 am. Deleted that comment as soon as I knew what I did I updated it immediately though with the correct path ^
trav$ otool -L /usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib
/usr/local/Cellar/mysql/5.7.17/lib/libmysqlclient.dylib:
/usr/local/opt/mysql/lib/libmysqlclient.20.dylib (compatibility version 20.0.0, current version 20.0.0)
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0) -
Not the MySQL client library, the Qt MySQL plugiin libqsqlmysql.dylib that can be found in the
plugins/sqldrivers
folder in your Qt installation. -
Not the MySQL client library, the Qt MySQL plugiin libqsqlmysql.dylib that can be found in the
plugins/sqldrivers
folder in your Qt installation.@SGaist
pwd
/Users/trav/Qt/5.6/clang_64/plugins/sqldriverstrav$ otool -L libqsqlmysql.dylib
libqsqlmysql.dylib:
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)
@rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
Traviss-Air:sqldrivers trav$ -
@SGaist
pwd
/Users/trav/Qt/5.6/clang_64/plugins/sqldriverstrav$ otool -L libqsqlmysql.dylib
libqsqlmysql.dylib:
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)
@rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)
Traviss-Air:sqldrivers trav$@Trav said in QMYSQL : Driver not loaded:
@SGaist
pwd
/Users/trav/Qt/5.6/clang_64/plugins/sqldriverstrav$ otool -L libqsqlmysql.dylib
libqsqlmysql.dylib:
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)Here's your problem... It is looking for mysql in the /opt/local/lib directory (which is a weird directory), when according to your post above it is in /usr/local/opt/mysql.
Usually people use /usr/local or /opt. I've never seen /opt/local. But it's not like there's set rules for directories or anything, so to each their own.
Anyway use
otool
to fix those paths and it should work. -
It's not weird for tools that are external to the distribution if we talk Linux style.
In this case, it's macports that is using it like that.
In any cas, the parameters passed to install_name_tool must be correct there's no error message telling you that the paths are invalid.