2013-07-10 69 views

回答

0

我會從源碼重建Qt,因爲您還需要SQL驅動程序(不僅僅是插件)。

驅動程序的源位於/ SRC/SQL /司機/ MySQL的
該插件的源位於/ SRC /插件/ sqldrivers

/src/sql/drivers/mysqldrivers.pri包含此:

contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri)

所以我認爲在編譯Qt之前,你需要運行configure,選項:-qt-sql-mysql-plugin-sql-mysql

重新編譯的Qt

  • 打開一個Qt 4.8.4命令提示符
  • cd \qtdir
  • nmake distclean
  • configure -debug-and-release -platform win32-msvc2010 -mp -nomake examples -nomake demos -qt-sql-mysql -plugin-sql-mysql
  • nmake

您可能需要點configure正確的包括/庫目錄爲MySQL,加入該選項:-I "c:\path\to\mysql\include"-L "c:\path\to\mysql\lib"

+0

謝謝你,我會嘗試。 –

+0

在我看來,你的時間最好花在構建插件上。您只需重建項目的插件部分,因爲QtSql模塊將在運行時動態加載DLL。從你上面提供的鏈接中,我假設你正在使用這個[guide](http://seppemagiels.com/blog/create-mysql-driver-qt-windows)。相反,你有沒有仔細看看你的[鏈接錯誤](http://stackoverflow.com/questions/10888391/link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-invalid-or -C)?? – Huy

+0

@Huytard:我認爲學習如何爲自己編譯和構建Qt框架總是很好的。因爲'configure'有很多選項,默認值並不總是你想要的(特別是在Windows上使用Qt時)。但是,我知道完整的重建需要幾個小時才能完成:) –