问题描述
QSqlDatabase:未加载QMYSQL驱动程序QSqlDatabase:可用驱动程序:QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
QSqlDatabase: QMYSQL driver not loadedQSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
我正在努力2天才能弄清楚.我做我的研究相信我.这些解决方案都不适合我.当我执行
I'm struggling for 2 days to figure it out. I did my research trust me. None of those solutions worked for me. When I execute
/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers$ ldd libqsqlmysql.so
我没有动态可执行文件.所以我想这不是一个好文件,因为当我在libqsqlite.lc上执行ldd时,我得到了
I get not a dynamic executable. So I guess it's not a good file because when I execute ldd on libqsqlite.so I get
linux-vdso.so.1 (0x00007f80db0f5000)
libQt5Sql.so.5 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f80da96d000)
libQt5Core.so.5 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f80da1bd000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f80d9f9e000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f80d9c15000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f80d9877000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f80d965f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f80d926e000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f80d9051000)
libicui18n.so.56 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f80d8bb8000)
libicuuc.so.56 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f80d8800000)
libicudata.so.56 => /home/bogdan/Qt5.13.2/5.13.2/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f80d6e1d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f80d6c19000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f80d6a17000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f80d6700000)
/lib64/ld-linux-x86-64.so.2 (0x00007f80daed0000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f80d648e000)
有人可以通过确切的步骤帮助我解决此问题.谢谢!!
Can someone help me to fix this problem with exact steps.Thanks in advance!
推荐答案
步骤:
-
安装上面找到的软件包的开发版本:
libmysqlclient-dev
从Qt安装中运行MaintenanceTool,并确保也选择安装Qt的源代码,或使用以下命令克隆项目:
Run the MaintenanceTool from your Qt installation, and be sure to select to install Qt's source code too, or clone the project using:
git clone -b YOUR_QT_VERSION https://github.com/qt/qtbase.git
或
git clone -b YOUR_QT_VERSION git://code.qt.io/qt/qtbase.git
在这种情况下,您的YOUR_QT_VERSION = 5.13.2)
in this case YOUR_QT_VERSION=5.13.2)
进入QTDIR/QT_VERSION/Src/qtbase/src/plugins/sqldrivers/
Go in QTDIR/QT_VERSION/Src/qtbase/src/plugins/sqldrivers/
运行正确的qmake,即来自Qt安装的那个qmake(不是系统范围的一个或类似的).最好的确定方法是提供完整的路径:QTDIR/QT_VERSION/gcc_64/bin/qmake sqldrivers.pro
Run the right qmake, i.e. the one coming from that installation of Qt (not the system wide one or similar). Best way to be sure is providing the full path to it: QTDIR/QT_VERSION/gcc_64/bin/qmake sqldrivers.pro
运行make && make install
这篇关于QMYSQL可用,但无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!