2010-08-16 82 views
0

在一個CentOS, Qt Creator的1.2.1 QTSDK-2009.04MySQL的QT在Linux和Windows

需要一步一步什麼創建MySQL驅動,在Linux和Windows。 這樣運行下面的命令給出一個正面的輸出

QSqlDatabase db = QSqlDatabase :: addDatabase(「QMYSQL」); db.setHostName(「xxxxxxxxxx」); db.setDatabaseName(「xxxxxxxdb」); db.setUserName(「xxxxxxxxxxx」); db.setPassword(「xxxxxxxxxxx」); bool ok = db.open();

Brgds,

kNish

回答

0

我曾經有過的PostgreSQL(8.3)驅動程序編譯successfully.Following是批處理CMDS做的工作(與你的替換路徑)。

cd D:\SoftwareSetup\Dev\Qt\2009.05\qt\src\plugins\sqldrivers\psql 

D:\SoftwareSetup\Dev\Qt\2009.05\qt\bin\qmake 「INCLUDEPATH+=D:\SoftwareSetup\Dev\PostgreSQL\8.3\include」 「LIBS+=D:\SoftwareSetup\Dev\PostgreSQL\8.3\lib\libpq.lib」 psql.pro 

@」D:\SoftwareSetup\Dev\Microsoft Visual Studio 9.0\VC\bin\nmake」 

「D:\SoftwareSetup\Dev\Qt\2009.05\mingw\bin\mingw32-make」 

pause 

如果使用VC編譯,使用NMAKE得到它的編譯, 我也參考以下兩個鏈接,找出庫的依賴關係:

http://lists.trolltech.com/qt-interest/2006-11/thread00265-0.html

http://doc.trolltech.com/4.6/sql-driver.html#how-to-build-the-qdts-plugin-on-windows

此頁面來自Nokia Qt文檔可能會對以下操作* nix(和Windows)有幫助:

http://doc.qt.nokia.com/4.6/sql-driver.html#supported-databases