PDA

View Full Version : [solved] mingw32 with Qt 4.7.0 - QMYSQL driver not loaded



schnitzel
9th December 2018, 23:00
hi folks,

I need to support an application I wrote a long time ago and was able to find the exact version of Qt I used, which is 4.7.0 (qt-sdk-win-opensource-2010.05.exe).
After installing SDK, the sources are already in c:/qt/2010.05/qt/src
Mingw is located at c:/qt/2010.05/mingw
c:/mysql/lib and include are installed

I'm currently stuck after reading the instructions from:
https://doc.qt.io/archives/qt-4.7/sql-driver.html

I followed the steps under 'How to build the MySQL driver for MinGW users'.
The step regarding reimp failed as I don't have reimp.exe on my system, so I looked at the options of dlltool and it seemed to have a -z option to output a .def from the .lib.
The subsequent configure step works, but after that mingw32-make sub-src fails with a bunch of unresolved symbols:

mingw32-make[2]: Entering directory `C:/Qt/2010.05/qt/src/sql'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -shared -Wl,--out-implib,c:\Qt\2010.05\qt\lib\libQtSqld4.a -o ..\..\lib\QtSqld4.dll object_script.QtSqld.Debug -L"c:\Qt\2010.05\qt\lib" -L"c:\Qt\2010.05\qt\lib" tmp\obj\debug_shared\QtSqld_resource_res.o -lmysql -Lc:\mysql\lib\opt -lQtCored4
Creating library file: c:\Qt\2010.05\qt\lib\libQtSqld4.a
./tmp\obj\debug_shared\qsql_mysql.o: In function `codec':
C:\Qt\2010.05\qt\src\sql/drivers/mysql/qsql_mysql.cpp:223: undefined reference to `mysql_character_set_name@4'
./tmp\obj\debug_shared\qsql_mysql.o: In function `qMakeError':
C:\Qt\2010.05\qt\src\sql/drivers/mysql/qsql_mysql.cpp:234: undefined reference to `mysql_error@4'
C:\Qt\2010.05\qt\src\sql/drivers/mysql/qsql_mysql.cpp:237: undefined reference to `mysql_errno@4'
./tmp\obj\debug_shared\qsql_mysql.o: In function `qMakeStmtError':
C:\Qt\2010.05\qt\src\sql/drivers/mysql/qsql_mysql.cpp:309: undefined reference to `mysql_stmt_error@4'
C:\Qt\2010.05\qt\src\sql/drivers/mysql/qsql_mysql.cpp:312: undefined reference to `mysql_stmt_errno@4'
./tmp\obj\debug_shared\qsql_mysql.o:C:\Qt\2010.05\qt \src\sql/drivers/mysql/qsql_mysql.cpp:358: undefined reference to `mysql_stmt_result_metadata@4'
./tmp\obj\debug_shared\qsql_mysql.o:C:\Qt\2010.05\qt \src\sql/drivers/mysql/qsql_mysql.cpp:362: undefined reference to `mysql_num_fields@4'

<snip>

./tmp\obj\debug_shared\qsql_mysql.o:C:\Qt\2010.05\qt \src\sql/drivers/mysql/qsql_mysql.cpp:1507: undefined reference to `mysql_real_escape_string@16'
collect2: ld returned 1 exit status
mingw32-make[2]: *** [..\..\lib\QtSqld4.dll] Error 1
mingw32-make[2]: Leaving directory `C:/Qt/2010.05/qt/src/sql'
mingw32-make[1]: *** [debug-all] Error 2
mingw32-make[1]: Leaving directory `C:/Qt/2010.05/qt/src/sql'
mingw32-make: *** [sub-sql-make_default-ordered] Error 2

I also tried the step under 'How to Build the QMYSQL Plugin on Windows' which succeeds and I end up with the following newly built files at c:/qt/2010.05/qt/plugins/sqldrivers:
libqsqlmysql(d)4.a
qsllmysql(d)4.dll

I realize this is an ancient version of Qt, but it would help me a lot if I can get this going first.

schnitzel
10th December 2018, 03:08
I have solved it by starting over from a fresh install of the SDK and then only perform the steps from How to build the QMYSQL Plugin on Windows from this page: https://doc.qt.io/archives/qt-4.7/sql-driver.html#qmysql
I then copied those libs to c:/qt/2010.05/bin/sqldrivers and the libmysql.dll to the folder with the app's exe.

There was no need to reconfigure Qt.