QSqlDatabase:未在 Ubuntu 15.04 64 位上加载 QMYSQL 驱动程序 [英] QSqlDatabase: QMYSQL driver not loaded on Ubuntu 15.04 64bits

查看:39
本文介绍了QSqlDatabase:未在 Ubuntu 15.04 64 位上加载 QMYSQL 驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 64 位 Ubuntu 15.04 中,我安装了 Qt5.6(在线安装程序),在尝试将我的开发环境从 Windows 7 迁移到 Linux 时,我遇到了以下问题:

In Ubuntu 15.04 64 bits I installed Qt5.6 (online installer) and while trying to move my development environment from Windows 7 to Linux I faced the following:

SqlDatabase: QMYSQL driver not loaded

this之后,我设法找到了~/Qt/5.6/gcc_64/plugins/sqldrivers/libqsqlmysql.so 然后:

Following this, I managed to find ~/Qt/5.6/gcc_64/plugins/sqldrivers/libqsqlmysql.so and then:

$ ldd libqsqlmysql.so
    linux-vdso.so.1 =>  (0x00007ffffd571000)
    libmysqlclient_r.so.16 => not found
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe94ef24000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fe94ecec000)
    libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fe94ead2000)
    libssl.so.10 => not found
    libcrypto.so.10 => not found
    libQt5Sql.so.5 => /home/user/Qt/5.6/gcc_64/plugins/sqldrivers/../../lib/libQt5Sql.so.5 (0x00007fe94e88d000)
    libQt5Core.so.5 => /home/user/Qt/5.6/gcc_64/plugins/sqldrivers/../../lib/libQt5Core.so.5 (0x00007fe94e17a000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe94df5c000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe94dc4d000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe94d944000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe94d72e000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe94d364000)
    libicui18n.so.56 => /home/user/Qt/5.6/gcc_64/plugins/sqldrivers/../../lib/libicui18n.so.56 (0x00007fe94cec9000)
    libicuuc.so.56 => /home/user/Qt/5.6/gcc_64/plugins/sqldrivers/../../lib/libicuuc.so.56 (0x00007fe94cb11000)
    libicudata.so.56 => /home/user/Qt/5.6/gcc_64/plugins/sqldrivers/../../lib/libicudata.so.56 (0x00007fe94b12e000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe94af29000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fe94ad27000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe94ab1f000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe94a80f000)
    /lib64/ld-linux-x86-64.so.2 (0x000056024837f000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe94a5a2000)

告诉 libmysqlclient_r.so.16 =>未找到.事实上,我似乎有一个更新的版本:

Tells libmysqlclient_r.so.16 => not found. In fact, it seems I have a newer version:

find / -name libmysqlclient_r*
/usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18
/usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.18.1.0
/usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
/usr/lib/x86_64-linux-gnu/libmysqlclient_r.a

也许这就是问题所在.有人能证实吗?我应该如何进行?

Perhaps that's the problem. Could some one confirm? How should I proceed?

推荐答案

首先,仔细检查您是否拥有包含 libssl.solibcrypto.so 的包和 libmysqlclient_r.so 安装(看起来你有最后一个,很可能你也有前两个,但只是仔细检查).

First and foremost, double check that you have the packages containing libssl.so, libcrypto.so and libmysqlclient_r.so installed (looks like you have this last one, it's extremely likely you also have the first two, but just double check).

然后,您的问题是您拥有那些具有不同 SONAME 的共享对象,表明它们与 Qt 附带的插件二进制不兼容,因此需要重新编译.

Then, your problem is that you have those shared objects with a different SONAME, sign that they're binary incompatible with the plugin shipped with Qt, which therefore needs to be recompiled.

因此:

  1. 安装上述软件包的开发版本(libssl-devmysql-client-dev 或类似的).

从您的 Qt 安装中运行 MaintenanceTool,并确保选择安装 Qt 的源代码.

run the MaintenanceTool from your Qt installation, and be sure to select to install Qt's source code too.

进入QTDIR/5.6/Src/qtbase/src/plugins/sqldrivers/mysql/.

运行 right qmake,即来自 Qt 安装的那个(不是系统范围的或类似的).确保提供完整路径的最佳方法是:QTDIR/5.6/gcc_64/bin/qmake.

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/5.6/gcc_64/bin/qmake.

运行make.希望这会奏效™;如果它抱怨缺少一些库,请安装它们并重新运行 make.

Run make. Hopefully this will just work™; if it complains about some missing libraries, install them and rerun make.

现在应该已经生成了一个新的libqsqlmysql.so 插件;用这个新的覆盖旧的.

This should now have produced a new libqsqlmysql.so plugin; overwrite the old one with this new one.

这篇关于QSqlDatabase:未在 Ubuntu 15.04 64 位上加载 QMYSQL 驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆