1. 安裝mysql的時(shí)候一定要安裝"Libs & Include Files"的開(kāi)發(fā)者模塊
2. 設(shè)置環(huán)境變量
PATH
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Qt\4.5.0\bin;C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
分別是以下幾個(gè)目錄:
%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
C:\Program Files\Microsoft SQL Server\90\Tools\binn\;
C:\Qt\4.5.0\bin;
C:\Program Files\Microsoft Visual Studio 8\VC\bin;
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
INCLUDE
C:\Program Files\Microsoft Visual Studio 8\VC\include;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;C:\Qt\4.5.0\include\QtCore;C:\Program Files\MySQL\MySQL Server 5.1\include
分別是以下幾個(gè)目錄
C:\Program Files\Microsoft Visual Studio 8\VC\include;
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;
C:\Qt\4.5.0\include;
C:\Program Files\MySQL\MySQL Server 5.1\include
LIBPATH
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB
分別是以下幾個(gè)目錄
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB
LIB
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;C:\Program Files\MySQL\MySQL Server 5.1\lib\debug;C:\Program Files\MySQL\MySQL Server 5.1\lib\opt
分別是以下幾個(gè)目錄:
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;
C:\Program Files\Microsoft Visual Studio 8\VC\LIB;
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;
C:\Program Files\MySQL\MySQL Server 5.1\lib\debug;
C:\Program Files\MySQL\MySQL Server 5.1\lib\opt
3. 為防止中文亂碼,修改mysql驅(qū)動(dòng)的源代碼
修改codec函數(shù),修改后為:
static QTextCodec* codec(MYSQL* mysql){return QTextCodec::codecForName("GBK");#if MYSQL_VERSION_ID >= 32321QTextCodec* heuristicCodec = QTextCodec::codecForName(mysql_character_set_name(mysql));if (heuristicCodec)return heuristicCodec;#endifreturn QTextCodec::codecForLocale();}
4. 執(zhí)行
cd C:\Qt\4.5.0\src\plugins\sqldrivers\mysql
qmake -o Makefile mysql.pro
nmake
如果成功就會(huì)在C:\Qt\4.5.0\plugins\sqldrivers目錄下產(chǎn)生一系列文件:
qsqlmysql4.dll
qsqlmysql4.exp
qsqlmysql4.lib
qsqlmysqld4.dll
qsqlmysqld4.exp
qsqlmysqld4.ilk
qsqlmysqld4.lib
qsqlmysqld4.pdb
聯(lián)系客服