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

xiaoxiao2021-02-27  449

网上找了好久,试了好多都不行,最后解决办法在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 packagesRun the MaintenanceTool (somewhere where you installed Qt)Ask it to install extra packagesInstall the "Source Components" for at least the Essential modulesGo to /dir/where/you/installed/Qt/version/Source/Go into qtbase/src/plugins/sqldrivers/mysqlRun 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.so, ldd 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下覆盖旧的文件。

转载请注明原文地址: https://www.6miu.com/read-560.html

最新回复(0)