1. 安裝mysql的時候一定要安裝"libs & include files"的開發者模組
2. 設定環境變數
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
分別是以下幾個目錄:
%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
分別是以下幾個目錄
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
分別是以下幾個目錄
c:/windows/microsoft.net/framework/v2.0.50727;
c:/program files/microsoft visual studio 8/vc/atlmfc/lib
libc:/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
分別是以下幾個目錄:
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驅動的源**
修改codec函式,修改後為:
cpp**
static qtextcodec* codec(mysql* mysql)
static qtextcodec* codec(mysql* mysql)
4. 執行
cd %qtdir%/src/plugins/sqldrivers/mysqlqmake -o makefile mysql.pro
nmake
如果成功就會在c:/qt/4.5.0/plugins/sqldrivers目錄下產生一系列檔案:
qsqlmysql4.dll
qsqlmysql4.exp
qsqlmysql4.lib
qsqlmysqld4.dll
qsqlmysqld4.exp
qsqlmysqld4.ilk
qsqlmysqld4.lib
qsqlmysqld4.pdb
這時我們需要將c:/mysql/bin 目錄下的libmysql.dll 檔案複製到我們qt creator 安裝目錄下的qt/bin 目錄中。
Qt編譯MySql驅動
我使用的環境是 vs2010 qt4.8.5 mysql5.6 首先,通過qt 4.8.5 command prompt進入qtdir src plugins sqldriver mysql目錄之下。而mysql預設安裝目錄是有空格的 program files mysql makefile無法準確...
QT的MYSQL驅動庫編譯
在qtcreator中開啟mysql.pro 修改兩個pro 檔案,下圖為改好 1.mysql.pro target qsqlmysql headers pwd qsql mysql p.h sources pwd qsql mysql.cpp pwd main.cpp qmake use mysq...
編譯MySQL驅動 與 Qt 連線 MySQL
0 假設你已經編譯安裝好了qt開發環境並可正常使用 假設用的是vs2008 qtvisualstudiointegrationv1.43for.vs.2003.2005 一切操作均在windows下進行。1安裝mysql 2將安裝好的mysql目錄下的include資料夾裡的檔案 標頭檔案 複製到編...