【发布时间】:2011-06-26 11:04:18
【问题描述】:
我正在尝试在 Qt 中制作一个依赖于 MySql 的应用程序。一段时间后,我知道我的共享构建没有 MySql 驱动程序(默认情况下)。任何人都可以说如何获取|编译它(共享和静态)。
注意:我在 Windows 平台上使用的是 Qt-4.7.2
编辑: 感谢“vrince”。这是他展示的方式 => 我做了。
1)Open qt-command prompt
2)Goto (Qt's installation path)\qt\src\plugins\sqldrivers\mysql
in my case:
D:\TempInstallationFolder\Qt\dynamic-New\qt\src\plugins\sqldrivers\mysql
3)qmake
4)make
or
mingw32-make (provided your PATH variable contains "(Qt installation path)\mingw\bin")
("make" should work if you didn't mess up with path variables. It in turn
invokes mingw32-make. I messed up this a little bit. So I invoked
mingw32-make directly.)
5)In the above command you have to indicate the mysql's "lib" path,
and "include" path through the compile flag options. Or Add those lines
in the pro file like below
INCLUDEPATH += "C:\Program Files\MySQL\MySQL Server 5.1\include"
LIBS += -L"C:\Program Files\MySQL\MySQL Server 5.1\lib\opt"
就是这样。您可以在 (Qt-安装路径)\qt\plugins\sqldrivers
【问题讨论】:
-
我按照上面的@Kiran Thilak 说明进行操作。运行后 C:\Qt\Qt5.14.2\5.14.2\Src\qtbase\src\plugins\sqldrivers\mysql>qmake mysql.pro 还需要运行如下命令:mingw32-make install
标签: c++ mysql windows database qt