Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMySql not loaded



  • First of all I must say I had spent almost two days searching a solution for this problem. I looked at a lot of forum posts regarding this and I couldn't find a solution.

    When I'am using QMySql driver to access mysql database in my localhost, it says,
    QMySql driver not loaded.
    *But it is in the list of available drivers.

    So far I have figured our there is a dependency problem in the libqsqlmysql.so (Located in /Qt/5.6/gcc_64/plugins/sqldriver/)

    Here's the output when I ran the "ldd libqsqlmysql.so" command.

    linux-vdso.so.1 =>  (0x00007ffeea366000)
    libmysqlclient_r.so.16 => not found
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9d02f94000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f9d02d5b000)
    libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f9d02b41000)
    libssl.so.10 => /lib/x86_64-linux-gnu/libssl.so.10 (0x00007f9d028e2000)
    libcrypto.so.10 => /lib/x86_64-linux-gnu/libcrypto.so.10 (0x00007f9d02506000)
    libQt5Sql.so.5 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f9d022c2000)
    libQt5Core.so.5 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f9d01bb0000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9d01992000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9d0168e000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9d01388000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9d01172000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9d00dad000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9d00ba9000)
    libicui18n.so.56 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f9d0070f000)
    libicuuc.so.56 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f9d00357000)
    libicudata.so.56 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f9cfe974000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f9cfe772000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9cfe56a000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f9cfe262000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9d033bf000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f9cfe024000)
    

    So it says libmysqlclient_r.so.16 not found.

    How to fix this error?
    Regards in advance.
    Please help me.


  • Moderators

    Hi @smb564 and Welcome,
    Your system is missing mysql client libraries. Use your distro's tool to install them.
    P. S. This question is quite common on this forum :)



  • @p3c0 Thank you for the reply.
    I installed them.
    I am using ubuntu. I have installed mysql-client & libmysqlclient-dev.
    Are those the files required?


  • Moderators

    @smb564 Well just the mysql client libraries unless you are recompiling the driver.
    Your system probably has a different version of that library.
    For eg. My system has libmysqlclient_r.so.18
    Create a symbolic link of the missing library to the library installed on your system.



  • I have created a symbolic link and now the output of ldd command changed as follows.
    ./libqsqlmysql.so: /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.16: version `libmysqlclient_16' not found (required by ./libqsqlmysql.so)
    linux-vdso.so.1 => (0x00007ffd91832000)
    libmysqlclient_r.so.16 => /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so.16 (0x00007f9479cce000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9479ab5000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f947987c000)
    libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f9479662000)
    libssl.so.10 => /lib/x86_64-linux-gnu/libssl.so.10 (0x00007f9479403000)
    libcrypto.so.10 => /lib/x86_64-linux-gnu/libcrypto.so.10 (0x00007f9479027000)
    libQt5Sql.so.5 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007f9478de3000)
    libQt5Core.so.5 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007f94786d1000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f94784b3000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f94781af000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9477ea9000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9477c93000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f94778ce000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f94776ca000)
    libicui18n.so.56 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007f9477230000)
    libicuuc.so.56 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007f9476e78000)
    libicudata.so.56 => /opt/Qt/5.6/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007f9475495000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f9475293000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f947508b000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f9474d83000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f947a418000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f9474b45000)


  • Moderators

    @smb564 Unfortunately linking is not sufficient it seems. Either you will need the exact version or you can compile the driver against the existing libraries. It is described here.



  • @p3c0 I don't know whether I am missing the obvious here. But I can't seem to find a folder like $QTDIR/qtbase/src/plugins/sqldrivers/mysql neither mysql.pro


  • Moderators

    @smb564 You will need to install the source components too. The installer provides an option during installation.



  • @p3c0 Thank you very much for your help! Now it works. :)

    I installed with source and followed the instructions in the Qt docs and manually built it.



  • @smb564 I had the same problem with QMYSQL not loaded. I ran
    $sudo apt-get installlibqt4-sql-mysql
    and it worked