Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QMYSQL driver available but not loaded

Tags:

mysql

qt

qt5

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?

like image 979
Hannoun Yassir Avatar asked Feb 02 '13 23:02

Hannoun Yassir


3 Answers

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
like image 117
Desmond Avatar answered Oct 28 '22 22:10

Desmond


ok it worked just by copying the sqldrivers folder to my debug folder and it worked!

like image 34
Hannoun Yassir Avatar answered Oct 29 '22 00:10

Hannoun Yassir


You could try diagnosing the issue with strace - it seems like the QMYSQL driver might need some run-time library dependencies to work.

like image 21
qdot Avatar answered Oct 28 '22 22:10

qdot