Results 1 to 2 of 2

Thread: QMYSQL driver not loaded but available

  1. #1
    Join Date
    Jan 2018
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QMYSQL driver not loaded but available

    I am trying to connect my Qt application with MySQL, and am getting the (notorious, it seems) QMSQL driver not loaded but available error. I have done research and read a number of possible solutions for this problem, but it seems as though there are a number of solutions and I am somewhat confused on what avenue to pursue for my particular case.

    I am using Qt 5.7.0 and Ubuntu 16.04.

    Here is my code to connect to the db:

    Qt Code:
    1. db = QSqlDatabase::addDatabase("QMYSQL");
    2. db.setHostName("host");
    3. db.setUserName("name");
    4. db.setPassword("password");
    5. db.setDatabaseName("dbName");
    6. bool ok = db.open();
    To copy to clipboard, switch view to plain text mode 

    Results of locate mysqlclient in terminal

    Qt Code:
    1. locate mysqlclient
    2.  
    3. /home/seth/libmysqlclient-dev_5.7.20-1ubuntu17.04_amd64.deb
    4. /home/seth/libmysqlclient20_5.7.20-1ubuntu17.04_amd64.deb
    5. /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20
    6. /usr/lib/x86_64-linux-gnu/libmysqlclient.so.20.3.7
    7. /usr/share/doc/libmysqlclient20
    8. /usr/share/doc/libmysqlclient20/COPYING.gz
    9. /usr/share/doc/libmysqlclient20/README
    10. /usr/share/doc/libmysqlclient20/changelog.Debian.gz
    11. /usr/share/doc/libmysqlclient20/copyright
    12. /usr/share/lintian/overrides/libmysqlclient20
    13. /var/cache/apt/archives/libmysqlclient20_5.7.20-1ubuntu16.04_amd64.deb
    14. /var/lib/dpkg/info/libmysqlclient20:amd64.list
    15. /var/lib/dpkg/info/libmysqlclient20:amd64.md5sums
    16. /var/lib/dpkg/info/libmysqlclient20:amd64.shlibs
    17. /var/lib/dpkg/info/libmysqlclient20:amd64.triggers
    To copy to clipboard, switch view to plain text mode 

    Results of ldd on sqldrivers
    Qt Code:
    1. ldd QTDIR/plugins/sqldrivers
    2.  
    3. linux-vdso.so.1 => (0x00007fffcf9d9000)
    4. libmysqlclient_r.so.16 => not found
    5. libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fab4c4c9000)
    6. libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fab4c290000)
    7. libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fab4c077000)
    8. libssl.so.10 => not found
    9. libcrypto.so.10 => not found
    10. libQt5Sql.so.5 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fab4be31000)
    11. libQt5Core.so.5 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fab4b716000)
    12. libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fab4b4f8000)
    13. libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fab4b176000)
    14. libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fab4ae6d000)
    15. libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fab4ac56000)
    16. libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fab4a88c000)
    17. libicui18n.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007fab4a3f2000)
    18. libicuuc.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007fab4a039000)
    19. libicudata.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007fab48656000)
    20. libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fab48452000)
    21. libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fab4824f000)
    22. librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fab48047000)
    23. libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fab47d36000)
    24. /lib64/ld-linux-x86-64.so.2 (0x00005576b7572000)
    25. libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fab47ac5000)
    To copy to clipboard, switch view to plain text mode 

    I believe line 2 above is the problem. So my question is essentially, how to I fix the libmysqlclient_r.so.16 => not found error?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QMYSQL driver not loaded but available

    Your second listing is not the result of the command at line 1. I assume you executed ldd on {QTDIR}/qt5/plugins/sqldrivers/libqsqlmysql.so.

    The Qt Mysql plugin for your Qt version has been built against an older Mysql client. You need to either:
    • Install an older Mysql client (libmysqlclient16 at a guess). The deb pacakge in /home/seth are from a later Ubuntu version, but the 16.04 xenial packages are also API version 20.
    • Build the Qt Mysql plugin from source matching your Qt version. You will need the relevant Mysql dev packages matching the client you have.

    Given that you seem to have your own local Qt 5.7 the second option may be easiest.

    The missing libcrypto and libssl are from OpenSSL.

Similar Threads

  1. QMYSQL driver not loaded
    By Erlkönig in forum Newbie
    Replies: 1
    Last Post: 2nd December 2016, 08:54
  2. CentOS 6: QMYSQL driver not loaded, available driver: (none)
    By mp33919 in forum Installation and Deployment
    Replies: 1
    Last Post: 19th October 2016, 16:46
  3. QMysql Driver not loaded
    By Cerberus in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2015, 20:55
  4. QMYSQL driver not loaded
    By stef1570 in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2011, 06:59
  5. QMYSQL driver not loaded
    By sepehr in forum Qt Programming
    Replies: 12
    Last Post: 11th January 2009, 21:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.