简体   繁体   English

找到但未加载MYSQL驱动程序

[英]MYSQL driver found but not loaded

QSqlDatabase: QMYSQL driver not loaded QSqlDatabase:未加载QMYSQL驱动程序

QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 QSqlDatabase:可用的驱动程序:QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

This is what I get when I'm trying to do anything with QSqlDatabase. 当我尝试使用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. 当我使用Linux时,我没有出现类似问题,但是现在我需要将应用程序移植到Windows,并且出现了此问题。 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. 但是发现它,因此在进行一些搜索之后,我发现我需要32位libmysql.dll文件-我已经拥有它。 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 :-1:错误:找不到-libmysql

collect2.exe:-1: error: error: ld returned 1 exit status collect2.exe:-1:错误:错误:ld返回了1个退出状态

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? 使它起作用的唯一方法是将libmysql.dll复制到应用程序的调试文件夹中,但是由于LGPL而我不能这样做,对吗?

The mysql page suggests that linking should be done with '-lmysqlclient' not -lmysql. mysql页面建议链接应使用'-lmysqlclient'而非-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." “在Windows上,您可以将代码与动态或静态C客户端库链接。静态库名为mysqlclient.lib,动态库名为libmysql.dll。此外,libmysql.lib静态导入库对于使用动态库。”

Also beware of the single threaded/multi-threaded issue. 还要提防单线程/多线程问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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