How do I load qmysql
driver in Qt? I have the following code that produces these results:
("QSQLITE", "QMYSQL", "QMYSQL3")
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3
Any suggestions on how to load it?
We should check our driver first
$ cd /opt/Qt5.2.1/5.2.1/gcc_64/plugins/sqldrivers
then we can find some files
Use the command below to check library
$ ldd libqsqlmysql.so
if you find the problem libmysqlclient_r.so.16 => not found
it may be the library-dependency problem.
After I did a little research on the Internet, there is a way would be easy.
$ cd /usr/lib/x86_64-linux-gnu
if you find libmysqlclient_r.so.18
,
$ cp libmysqlclient_r.so.18 libmysqlclient_r.so.16
ok it worked just by copying the sqldrivers
folder to my debug folder and it worked!
You could try diagnosing the issue with strace
- it seems like the QMYSQL driver might need some run-time library dependencies to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With