Home > Database > Mysql Tutorial > body text

Windows下编译Qt的Mysql驱动_MySQL

WBOY
Release: 2016-06-01 13:06:49
Original
1405 people have browsed it
<em>系统:Windows 7Qt版本:4.8.5Qt Creator版本:2.8.0  安装路径:Qt -> D:/Qt4.8.5Qt Creator -> D:/Qtcreator-2.8.0mingw -> D:/mingw</em> 1.配置环境变量:到“我的电脑->属性->高级->环境变量->系统变量”中编辑Path,添加:我电脑的安装路 ;D:/Qt4.8.5/bin;D:/Qtcreator-2.8.0/bin;D:/mingw/bin确定;为了让环境变量生效,如果配置环境变量之前已经打开cmd,要重新打开一个新的cmd窗口。 2.下载mysql官网www.mysql.com下载,非安装包的文件名称类似这种格式:mysql-5.5.29-win32.zip只需要mysql里面的lib和include,解压到D:/ 3.下载mingw-utils-0.3.tar.gz解压出来,将bin文件夹里面的reimp.exe拷贝到D:/Qt/qtcreator-2.4.1/mingw/bin目录,不拷贝也行,调用reimp手动添加绝对路径。 4.编译驱动打开cmd,执行以下命令:(1)转换libmysql格式cd d:/mysql/libreimp -d libmysql.libdlltool -k -d libmysql.def -l libmysql.a(2)编译qt的mysql驱动cd d:/Qt4.8.0/src/plugins/sqldrivers/mysqlqmake "CONFIG+=release" -o Makefile "INCLUDEPATH+=d:/mysql/include" "LIBS+=d:/mysql/lib/libmysql.a" mysql.promingw32-makeqmake "CONFIG+=debug" -o Makefile "INCLUDEPATH+=d:/mysql/include" "LIBS+=d:/mysql/lib/libmysql.a" mysql.promingw32-make 5.拷贝mysql驱动编译完成后,打开D:/Qt4.8.0/src/plugins/sqldrivers/mysql目录,可以看到release和debug目录,分别从release和debug目录中拷贝以下4个文件到D:/Qt4.8.0/plugins/sqldrivers:qsqlmysql4.dlllibqsqlmysql4.aqsqlmysqld4.dlllibqsqlmysqld4.a 6.拷贝mysql动态库(重要)(1)本机运行拷贝D:/mysql/lib/libmysql.dll文件到D:/Qt4.8.0/bin (2)发布应用程序没有mysql的电脑,若要发布应用程序,要跟着libmysql.dll一块发布,与应用程序同级目录。 7.测试mysql可用性加入已经存在mysql服务,那么编写以下代码测试:(1).测试是否有驱动QStringList driverList = QSqlDatabase::drivers();  qDebug() 
    
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template