[英]Mysql Driver not loaded on Qt5.4 OS X Yosemite
I just did a fresh install of Yosemite on my mac. 我刚刚在我的Mac上安装了Yosemite。 Installed Xcode, Qt5.4and mysql CE
安装了Xcode,Qt5.4和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 : 我检查了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. 我没有/opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib文件,事实上我没有在我的Yosemite mac上有/ opt文件夹。 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. 我尝试自己重新创建/ opt / local / lib / mysql55 / mysql /文件夹并在其中添加了libmysqlclient.18.dylib,但我仍然遇到同样的问题。
I'm now completely clueless about how to resolve this, Am I doing something wrong? 我现在完全不知道如何解决这个问题,我做错了什么? is this a Yosemite vs MySQL bug?
这是Yosemite vs MySQL的错误吗?
I think my .pro file and sources are ok as this used to work under my previous Mavericks config. 我认为我的.pro文件和源代码都可以,因为这曾经在我以前的Mavericks配置下运行。
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/
). 在你的机器上搜索
libmysqlclient.18.dylib
,找到实际存在此文件副本的位置(我的位于/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. 然后使用
install_name_tool
命令与-change
标志指向你libqmysql.dylib
它。 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. 确保为调试版本
libqsqlmysql_debug.dylib
运行相同的命令,以便您的调试版本也指向正确的lib。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.