我按照本教程使用VS2010編譯mysql驅動程序: Qt - How to get|compile Mysql driver。Qt - Trying mysql驅動程序
編譯失敗,出現錯誤:LNK1123: failure during conversion to COFF: file invalid or corrupt
我試着用MySQL和QT的多個版本,我總是得到同樣的錯誤。
注意:我正在使用Qt-4.8.4和mysql-5.5.32-win32。
我按照本教程使用VS2010編譯mysql驅動程序: Qt - How to get|compile Mysql driver。Qt - Trying mysql驅動程序
編譯失敗,出現錯誤:LNK1123: failure during conversion to COFF: file invalid or corrupt
我試着用MySQL和QT的多個版本,我總是得到同樣的錯誤。
注意:我正在使用Qt-4.8.4和mysql-5.5.32-win32。
我會從源碼重建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
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"
謝謝你,我會嘗試。 –
在我看來,你的時間最好花在構建插件上。您只需重建項目的插件部分,因爲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
@Huytard:我認爲學習如何爲自己編譯和構建Qt框架總是很好的。因爲'configure'有很多選項,默認值並不總是你想要的(特別是在Windows上使用Qt時)。但是,我知道完整的重建需要幾個小時才能完成:) –