0

I followed this tutorial to compile mysql driver with VS2010 : Qt - How to get|compile Mysql driver.

The compilation fails with the error : LNK1123: failure during conversion to COFF: file invalid or corrupt

I tried with with multiple versions of mysql and qt, i always get the same error.

Note: I am using Qt-4.8.4 and mysql-5.5.32-win32.

Community
  • 1
  • 1

1 Answers1

0

I would rebuild Qt from source, because you also need the SQL driver (not only the plugin).

The driver source is located under /src/sql/drivers/mysql
The plugin source is located under /src/plugins/sqldrivers

/src/sql/drivers/mysqldrivers.pri contains this:

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

So I think that you need to run configure with the options: -qt-sql-mysql and -plugin-sql-mysql before compiling Qt.

Recompile Qt

  • Open a Qt 4.8.4 Command Prompt
  • cd \qtdir
  • nmake distclean
  • configure -debug-and-release -platform win32-msvc2010 -mp -nomake examples -nomake demos -qt-sql-mysql -plugin-sql-mysql
  • nmake

You might need to point configure to the correct include/library directory for MySQL, by adding this options: -I "c:\path\to\mysql\include" and -L "c:\path\to\mysql\lib"

huysentruitw
  • 27,376
  • 9
  • 90
  • 133
  • In my opinion, your time is best spent building only the plugin. You only need to rebuild the plugin section of the project because the QtSql module will dynamically load the DLL at run-time. From the link you provided above, I assume you're using this [guide](http://seppemagiels.com/blog/create-mysql-driver-qt-windows). Instead, have you taken a closer look at your [link error](http://stackoverflow.com/questions/10888391/link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-invalid-or-c)?? – Son-Huy Pham Jul 10 '13 at 15:56
  • @Huytard: I think it's always good to learn how to compile and build the Qt framework for yourself. Because `configure` has many options and the defaults aren't always what you want (especially when using Qt on Windows). But, I'm aware a full rebuild takes a few hours to complete :) – huysentruitw Jul 10 '13 at 20:30
  • Re-installation of visual studio corrected my error. I guess my problem is related to this one [link](http://stackoverflow.com/questions/10888391/link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-invalid-or-c/14144713#14144713), since i was using VS2012 earlier. – anouar moulkaf Jul 11 '13 at 08:14