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:
db.setHostName("host");
db.setUserName("name");
db.setPassword("password");
db.setDatabaseName("dbName");
bool ok = db.open();
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("host");
db.setUserName("name");
db.setPassword("password");
db.setDatabaseName("dbName");
bool ok = db.open();
To copy to clipboard, switch view to plain text mode
Results of locate mysqlclient in terminal
locate mysqlclient
/home/seth/libmysqlclient-dev_5.7.20-1ubuntu17.04_amd64.deb
/home/seth/libmysqlclient20_5.7.20-1ubuntu17.04_amd64.deb
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.20
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.20.3.7
/usr/share/doc/libmysqlclient20
/usr/share/doc/libmysqlclient20/COPYING.gz
/usr/share/doc/libmysqlclient20/README
/usr/share/doc/libmysqlclient20/changelog.Debian.gz
/usr/share/doc/libmysqlclient20/copyright
/usr/share/lintian/overrides/libmysqlclient20
/var/cache/apt/archives/libmysqlclient20_5.7.20-1ubuntu16.04_amd64.deb
/var/lib/dpkg/info/libmysqlclient20:amd64.list
/var/lib/dpkg/info/libmysqlclient20:amd64.md5sums
/var/lib/dpkg/info/libmysqlclient20:amd64.shlibs
/var/lib/dpkg/info/libmysqlclient20:amd64.triggers
locate mysqlclient
/home/seth/libmysqlclient-dev_5.7.20-1ubuntu17.04_amd64.deb
/home/seth/libmysqlclient20_5.7.20-1ubuntu17.04_amd64.deb
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.20
/usr/lib/x86_64-linux-gnu/libmysqlclient.so.20.3.7
/usr/share/doc/libmysqlclient20
/usr/share/doc/libmysqlclient20/COPYING.gz
/usr/share/doc/libmysqlclient20/README
/usr/share/doc/libmysqlclient20/changelog.Debian.gz
/usr/share/doc/libmysqlclient20/copyright
/usr/share/lintian/overrides/libmysqlclient20
/var/cache/apt/archives/libmysqlclient20_5.7.20-1ubuntu16.04_amd64.deb
/var/lib/dpkg/info/libmysqlclient20:amd64.list
/var/lib/dpkg/info/libmysqlclient20:amd64.md5sums
/var/lib/dpkg/info/libmysqlclient20:amd64.shlibs
/var/lib/dpkg/info/libmysqlclient20:amd64.triggers
To copy to clipboard, switch view to plain text mode
Results of ldd on sqldrivers
ldd QTDIR/plugins/sqldrivers
linux-vdso.so.1 => (0x00007fffcf9d9000)
libmysqlclient_r.so.16 => not found
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fab4c4c9000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fab4c290000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fab4c077000)
libssl.so.10 => not found
libcrypto.so.10 => not found
libQt5Sql.so.5 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fab4be31000)
libQt5Core.so.5 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fab4b716000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fab4b4f8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fab4b176000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fab4ae6d000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fab4ac56000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fab4a88c000)
libicui18n.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007fab4a3f2000)
libicuuc.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007fab4a039000)
libicudata.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007fab48656000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fab48452000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fab4824f000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fab48047000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fab47d36000)
/lib64/ld-linux-x86-64.so.2 (0x00005576b7572000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fab47ac5000)
ldd QTDIR/plugins/sqldrivers
linux-vdso.so.1 => (0x00007fffcf9d9000)
libmysqlclient_r.so.16 => not found
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fab4c4c9000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fab4c290000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fab4c077000)
libssl.so.10 => not found
libcrypto.so.10 => not found
libQt5Sql.so.5 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Sql.so.5 (0x00007fab4be31000)
libQt5Core.so.5 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libQt5Core.so.5 (0x00007fab4b716000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fab4b4f8000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fab4b176000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fab4ae6d000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fab4ac56000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fab4a88c000)
libicui18n.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicui18n.so.56 (0x00007fab4a3f2000)
libicuuc.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicuuc.so.56 (0x00007fab4a039000)
libicudata.so.56 => /home/seth/Qt5.7.0/5.7/gcc_64/plugins/sqldrivers/./../../lib/libicudata.so.56 (0x00007fab48656000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fab48452000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fab4824f000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fab48047000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fab47d36000)
/lib64/ld-linux-x86-64.so.2 (0x00005576b7572000)
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?
Bookmarks