简体   繁体   中英

MYSQL driver found but not loaded

QSqlDatabase: QMYSQL driver not loaded

QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

This is what I get when I'm trying to do anything with QSqlDatabase. I had no problem like that when I was using Linux but now I need to port my application to Windows and this problem occured. I know that if the driver is unable to be found - I need to build it. But it is found so after some searching I've found that I need 32-bit libmysql.dll file - I have it already. I'm trying to add it to my project like that:

INCLUDEPATH += C:\\Program Files (x86)\\MySQL\\MySQL Server 5.6\\lib
DEPENDPATH += C:\\Program Files (x86)\\MySQL\\MySQL Server 5.6\\lib

or like that:

LIBS += -L"C:\\Program Files (x86)\\MySQL\\MySQL Server 5.6\\lib" -libmysql

but the first way is not giving me any output (I'm not even sure about the syntax) and the second returns error:

:-1: error: cannot find -libmysql

collect2.exe:-1: error: error: ld returned 1 exit status

The only way I can make it work is to copy libmysql.dll into my application's debug folder but I can't do that because of LGPL, right?

The mysql page suggests that linking should be done with '-lmysqlclient' not -lmysql.

"On Windows, you can link your code with either the dynamic or static C client library. The static library is named mysqlclient.lib and the dynamic library is named libmysql.dll. In addition, the libmysql.lib static import library is needed for using the dynamic library."

Also beware of the single threaded/multi-threaded issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM