插件已编译并安装在此处qt-project.org。
libqt5sql5-mysql
已安装mysql-client
已安装代码:
QPluginLoader loader("path-to-your-driver/libqsqlmysql.so");
loader.load();
qDebug() << loader.errorString();
显示
"Unknown error"
qDebug() << QSqlDatabase::drivers();
“QSQLITE”,“QMYSQL”,“QMYSQL3”,“QPSQL”,“QPSQL7”
我有
$ls -l /Qt/5.4/gcc_64/plugins/sqldrivers/
libmysqlclient.so.18.1.0
libqsqlite.so
libqsqlmysql.so
libqsqlpsql.so
和
$ldd libqsqlmysql.so
linux-vdso.so.1 => (0x00007fff381bf000)
libmysqlclient.so.18 => /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18 (0x00007f67e891a000)
libQt5Sql.so.5 => /home/maxim/Qt/5.4/gcc_64/lib/libQt5Sql.so.5 (0x00007f67e86da000)
libQt5Core.so.5 => /home/maxim/Qt/5.4/gcc_64/lib/libQt5Core.so.5 (0x00007f67e7f9d000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f67e7c99000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f67e78d3000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f67e76b9000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f67e74b5000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f67e7297000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f67e6f90000)
libicui18n.so.53 => /home/maxim/Qt/5.4/gcc_64/lib/libicui18n.so.53 (0x00007f67e6b44000)
libicuuc.so.53 => /home/maxim/Qt/5.4/gcc_64/lib/libicuuc.so.53 (0x00007f67e67b9000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f67e65b6000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f67e63ae000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f67e60a6000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f67e5e8f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f67e9086000)
libicudata.so.53 => /home/maxim/Qt/5.4/gcc_64/lib/libicudata.so.53 (0x00007f67e4807000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f67e45c8000)