Ubuntu16.04 QT "QMYSQL driver not loaded on Ubuntu"问题

网上找了好久,试了好多都不行,最后解决办法在http://stackoverflow.com/questions/33348612/mysql-qt-qmysql-driver-not-loaded找到的,我依照第二个答主的办法成功了。

原文:

Assuming that for getting this error you installed Qt from the binary packages downloaded from qt.io:

  • Install the MySQL client dev packages
  • Run the MaintenanceTool (somewhere where you installed Qt)
  • Ask it to install extra packages
  • Install the "Source Components" for at least the Essential modules
  • Go to /dir/where/you/installed/Qt/version/Source/
  • Go into qtbase/src/plugins/sqldrivers/mysql
  • Run qmake from the very same Qt version (/dir/where/you/installed/Qt/version/arch/bin/qmake or similar)
  • Run make, if it explodes with headers/libraries not found check that you installed those MySQL client dev packages correctly

That should give you a brand new plugin, and with fingers crossed, it's already put in the right place. Otherwise find the new libqsqlmysql.soldd it to be sure it was OK, and overwrite the old plugin with the new one.


翻译一下:

1. 安装 MySQL client dev 这个包可以通过 

sudo apt-get install libmysqlclient-dev

安装。

2. 安装QT,安装的时候选择组件选择所有组件,如果已经安装完成,可以使用安装目录下的 "MaintenanceTool" 文件来添加组件,不过这个离线版的安装包好像有BUG,不能添加,最后我删除重装QT。。。

3.  切换至  [QT安装目录]/[version]/Src/qtbase/src/plugins/sqldrivers/mysql 目录下

4. 运行qmake命令,编译mysql.pro 即

qmake mysql.pro

如果qmake没有添加到环境变量,则使用qmake的完整路径( [QT安装目录]/[version]/gcc_64/bin/qmake)。

5. 运行make,运行成功的最后一行应该是"mv  -f  libqsqlmysql.so ../../../../plugins/sqldrivers/"

6. 到上面那个目录下找到 libqsqlmysql.so 文件拷贝到 [QT安装目录]/[version]/gcc_64/plugins/sqldrivers下覆盖旧的文件。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值