Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
645 views
in Technique[技术] by (71.8m points)

c++ - QSqlDatabase: QMYSQL driver not loaded on Ubuntu 15.04 64bits

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

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)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).

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.

Therefore:

  1. install the development versions of the packages found above (libssl-dev, mysql-client-dev or similar).

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

  3. Go in QTDIR/5.6/Src/qtbase/src/plugins/sqldrivers/mysql/.

  4. 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.

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...