Qt5.9.1 QMYSQL 驱动程序无法加载

Qt5.9.1 QMYSQL 驱动程序无法加载

我已经尝试修复它,但没有任何效果...这里列出了我已经做过的事情(我是 Linux 的初学者,所以我可能无法执行解决方案...)

  1. sudo ./configure -sql-mysql我确实用sudo make和编译了源代码,sudo make install结果/opt/Qt/5.9.1/src/正在/usr/Qt-5.9.1/创建,并且其中包含文件,包括“plugins / sqldrivers / libqsqlmysql.so
  2. 我安装了(它们已经安装了)mysql-server, mysql-server-5.7, mysql-client, mysql-client-5.7。我的 Apache 服务器运行的 MySQL 版本是 5.7
  3. .pro我在文件 QT += sql、、、、中添加了变量,但是当我这样做时,QTPLUGIN += qsqlmysql我收到一条命令未找到错误。CONFIG += c++11INCLUDEPATH += /usr/include/mysql \ /usr/local/Qt-5.9.1/plugins/sqldrivers \ /usr/local/Qt-5.9.1 \ /usr/local/Qt-5.9.1/libLIBS+=-L/usr/lib -lmysqlclient_rINCLUDEPATH+=/usr/local/Qt-5.9.1/plugins/sqldrivers/libqsqlmysql.socd /usr/bin-lmysqlclient_r
  4. 我也做了一些与ln命令相关的事情,但我找不到找到答案的链接,所以我不确定它到底做了什么。

我不知道它是否重要,但是我的 ide 设置为 Qt 5.9.1 并使用 qmake 版本 5.9.1,但我确实使用 apt 下载了一些 qt 4 的东西,所以当我qmake -v在命令行中有版本 5.5.1 时。

我考虑下载 30 天试用商业版来获取已编译的驱动程序,但我不确定试用期何时到期,我是否仍然可以使用该QMYSQL驱动程序。

/usr/lib$ ls | grep sql libmysqlclient_r.so libmysqlclient_r.so.18 libmysqlpp.so.3 libmysqlpp.so.3.2.2 libsqlite.so.0 libsqlite.so.0.8.6 mysql

以下是我安装的软件包列表

sudo dpkg --get-selections | grep qt appmenu-qt:amd64 install appmenu-qt5 install libaccounts-qt5-1:amd64 install libdbusmenu-qt2:amd64 install libdbusmenu-qt5:amd64 install libgsettings-qt1:amd64 install liboxideqt-qmlplugin:amd64 install liboxideqtcore0:amd64 install liboxideqtquick0:amd64 install libqt4-dbus:amd64 install libqt4-declarative:amd64 install libqt4-designer:amd64 install libqt4-dev install libqt4-dev-bin install libqt4-help:amd64 install libqt4-network:amd64 install libqt4-opengl:amd64 install libqt4-opengl-dev install libqt4-qt3support:amd64 install libqt4-script:amd64 install libqt4-scripttools:amd64 install libqt4-sql:amd64 install libqt4-sql-mysql:amd64 install libqt4-sql-sqlite:amd64 install libqt4-svg:amd64 install libqt4-test:amd64 install libqt4-xml:amd64 install libqt4-xmlpatterns:amd64 install libqt5concurrent5:amd64 install libqt5core5a:amd64 install libqt5dbus5:amd64 install libqt5feedback5:amd64 install libqt5gui5:amd64 install libqt5multimedia5:amd64 install libqt5network5:amd64 install libqt5opengl5:amd64 install libqt5opengl5-dev:amd64 install libqt5organizer5:amd64 install libqt5positioning5:amd64 install libqt5printsupport5:amd64 install libqt5qml5:amd64 install libqt5quick5:amd64 install libqt5quicktest5:amd64 install libqt5sql5:amd64 install libqt5sql5-mysql:amd64 install libqt5sql5-sqlite:amd64 install libqt5svg5:amd64 install libqt5test5:amd64 install libqt5webkit5:amd64 install libqt5widgets5:amd64 install libqt5xml5:amd64 install libqtcore4:amd64 install libqtdbus4:amd64 install libqtgui4:amd64 install libsignon-qt5-1:amd64 install libunity-action-qt1:amd64 install oxideqt-codecs:amd64 install qml-module-qt-labs-folderlistmodel:amd64 install qml-module-qt-labs-settings:amd64 install qml-module-qtfeedback:amd64 install qml-module-qtgraphicaleffects:amd64 install qml-module-qtquick-layouts:amd64 install qml-module-qtquick-window2:amd64 install qml-module-qtquick2:amd64 install qml-module-qttest:amd64 install qt-at-spi:amd64 install qt4-linguist-tools install qt4-qmake install qt5-default:amd64 install qt5-qmake:amd64 install qt5-qmake-arm-linux-gnueabihf:amd64 install qtbase5-dev:amd64 install qtbase5-dev-tools install qtchooser install qtcore4-l10n install qtdeclarative5-accounts-plugin:amd64 install qtdeclarative5-dev-tools install qtdeclarative5-qtquick2-plugin:amd64 install qtdeclarative5-test-plugin:amd64 install qtdeclarative5-ubuntu-ui-toolkit-plugin install qtdeclarative5-unity-action-plugin:amd64 install qttranslations5-l10n install sni-qt:amd64 install


sudo dpkg --get-selections | grep mysql dbconfig-mysql install libmysql++3v5 install libmysql-java install libmysqlclient-dev install libmysqlclient16:amd64 install libmysqlclient20:amd64 install libqt4-sql-mysql:amd64 install libqt5sql5-mysql:amd64 install mysql-apt-config install mysql-client install mysql-client-5.7 install mysql-client-core-5.7 install mysql-common install mysql-server install mysql-server-5.7 install mysql-server-core-5.7 install php-mysql install php7.0-mysql install

答案1

遇到了同样的问题,经过谷歌研究和直觉,终于解决了这个问题。使用 Qt5.9.1 和 Ubuntu 17.10

libmysqlclient.so.18 => not found首先,检查是否存在错误

    :~/Qt5.9.1/5.9.1/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so

其次,搜索libmysqlclient在哪里

    :/$ locate libmysqlclient 

第三,转到 libmysqlclient 所在的文件夹并在那里建立链接

    :/usr/lib/x86_64-linux-gnu$ sudo ln -s libmysqlclient.so.20 libmysqlclient.so.18

并使用以下方式检查之前建立的链接

    ls -alh | grep libmysql

那时,这些问题都没有解决,于是我决定进一步研究 synaptic 软件包,发现libqt5sql5-mysql没有安装 5.9.1 版本,所以安装它解决了问题,但在执行 ldd 时仍然收到一条消息

./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18: 未找到版本“libmysqlclient_18”(./libqsqlmysql.so 所需)

之后,我找到了一些链接,它们可以引导我找到真正的解决方案,如果你想知道发生了什么,它们就在这里

我下载了第三个链接中提到的库,并且运行良好。希望它有帮助!

https://www.unix.com/unix-for-advanced-and-expert-users/107611-difference-between-libsqlclient-so-libsqlclient_r-so.html

http://www.tango-controls.org/community/forum/c/general/installation/ubuntu-1604-problem-installing-from-source-code-libmysqlclient-replaces-libmysqlclient_r/

https://superuser.com/questions/1101426/installing-libmysqlclient18-on-ubuntu-16-04?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa&newreg=9c558283c488461aaf597ef1132e4ca0

相关内容