一步步学Qt,第二天-续集:mysql driver

学习qt已经两天了,现在打算开始使用qt来连接mysql,先前在linux下面写过一个程序,不过没有mysqldirver所以连接失败了.后来才知道,原来qt连接mysql的dirver需要自己编译的.现在在windows里面.所以要自己把这个驱动给编译好了.不过还不知道如何开始编译,那就问问qt助手咯

打开qt助手,切换视图到index输入SQL Database Drivers,在右边就会出现很多的选择,我使用的是mingw,所以我点击了How to build the MySQL driver for MinGW users,

下面是内容:

How to build the MySQL driver for MinGW users

The following steps have been used successfully for WinXP SP3. In this example, Qt 4.6.2 is shown.

  • Download the following components:
    • MinGW-5.1.6.exe
    • mingw-utils-0.3.tar.gz
    • Qt sources, e.g. qt-everywhere-opensource-src-4.6.2.zip
    • mysql-5.1.35-win32.msi
  • Install MinGW-5.1.6.exe in, e.g. C:\MinGW.
  • Extract mingw-utils-0.3.tar.gz into, e.g. C:\MinGW.
  • Add the path for MinGW-5.1.6.exe to your PATH variable, e.g. C:\MinGW\bin;
  • Extract the Qt sources, (qt-everywhere-opensource-src-4.6.2.zip), into, e.g. C:\Qt.
  • Add the path for the eventual Qt binary to your PATH variable, e.g. C:\Qt\4.6.2\bin;.
  • Install MySQL (mysql-5.1.35-win32.msi), customizing the components. Select only the headers and libraries. Install in, e.g.C:\MySQL\MySQL51.
  • Open the DOS prompt, go to C:\MySQL\MySQL51\lib\opt, and run the following commands:
    • reimp -d libmysql.lib
    • dlltool -k -d libmysql.def -l libmysql.a
  • Open the DOS prompt, go to C:\Qt\4.6.2 and run the following commands:
    • configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -l mysql -I C:\MySQL\MySQL51\include -L C:\MySQL\MySQL51\lib\opt
    • mingw32-make sub-src

    This step takes a long time.

  • Open the DOS prompt, go to C:\Qt\4.6.2\src\plugins\sqldrivers\mysql and run the following command:
    • qmake "INCLUDEPATH+=C:\MySQL\MySQL51\include" "LIBS+=-L. mysql" mysql.pro
  • Now the following libraries are ready in C:\Qt\4.6.2\plugins\sqldrivers.
    • libqsqlmysql4.a
    • libqsqlmysqld4.a
    • qsqlmysql4.dll
    • qsqlmysqld4.dll

    To use the SDK and QtCreator directly, copy these libraries to your C:\Qt\...\qt\plugins\sqldrivers\, and copyC:\MySQL\MySQL51\lib\opt\libmysql.dll to your C:\Qt\...\qt\bin\.

在看到上面的内容的时候出现了几个问题:

一. QT 的opensource和sdk的区别和关系

因为在opensource版本里面貌似也有designer和assistant等等的,可能就是没有qtcreator

在这两个版本里面很多的东西都是重复的,不得不说是占地方

二. 我的mysql版本问题

我的mysql版本是5.1.74的,assistant中说的是5.1.35,不过我没有在mysql的目录下找到lib\opt这个目录...后来我猜发现,我用 了这么 久的mysql,原来我用的mysql只是一个精简版.汗!!!!

----------------------------------------------------------------------------------


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值