Qt5 MySQL crash on opening database
I'm using Qt 5.0.0 on Windows 7 x64 (personal compile - MinGW x64). I added MySQL support in configuration and also MySQL is installed on system. MySQL libraries, headers and are visible in application.
Program crashes on opening database. I open database like this:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("My DB name");
qDebug() << QSqlDatabase::drivers();
("QMYSQL3", "QMYSQL", "QODBC3", "QODBC", "QSQLITE")
What is difference between QMYSQL3 and QMYSQL ? I tried both and program crashes when opening database.
AFAIK MySQL driver is compiled with MSVC. I'm using MinGW. Can this be related to binary incompatibility ?
Problem Event Name: APPCRASH
Application Name: CMS.exe
Application Version: 0.0.0.0
Application Timestamp: 51010cdd
Fault Module Name: Qt5Sql.dll
Fault Module Version: 22.214.171.124
Fault Module Timestamp: 50f6b734
Exception Code: c0000005
Exception Offset: 00000000000df950
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: db69
Additional Information 2: db697f824a06df6631cf05ed1f197e16
Additional Information 3: 1d76
Additional Information 4: 1d7605bf295c1c2cfcbfc6bfcec7c569
I generate .a file using gendef and dlltool :
dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a
And add a link to libmysql in my .pro file.
hey soroush, does this problem exists on 32 bit version too? i've recently tried with 32bit mingw/Qt and that was same issue. the message indicates that mysql driver is not loaded while then lists mysql as an available driver.
[quote author="Mohsen" date="1359974901"]hey soroush, does this problem exists on 32 bit version too? i've recently tried with 32bit mingw/Qt and that was same issue. the message indicates that mysql driver is not loaded while then lists mysql as an available driver.[/quote]
I'm going to test it tonight
Update: Just tested. Works fine for 32bit MySQL. 64 bit is still problematic. I guess it could be a matter of none-standard code in Qt code which cause an optimization pitfall. The -O3 optimization level is known as dangerous for some architectures. I'm going to test a new compile with no optimization in 64 bit machine tonight