[SOLVED]Trying to build mysql driver in Qt 5.1.0 and MySQL 5.6
-
I have the same problem "Makefile.Release:65: *** missing separator"
and i looked in Makefile.Release and didn't find missing separator)
There were my steps:-
create folder [tempMySQL] with include and lib folders from mysqlserver folder
It's look like this
c:\qt\qt5.3.1\tempMySQL -
open mingw console and go to "C:\Qt\Qt5.3.1\5.3\Src\qtbase\src\plugins\sqldrivers\mysql"
-
qmake "INCLUDEPATH+=C:\Qt\Qt5.3.1\tempMySQL\include" "LIBS+=C:\Qt\Qt5.3.1\tempMySQL\libmysql.lib" mysql.pro
-
mingw32-make
I didn't build Qt5.3.1 by myself, i just download
Qt 5.3.1 for Windows 32-bit (MinGW 4.8.2, OpenGL, 737 MB) (Info) from hereAnd when i worked with Qt 4.8.4 with VS2010 i didn't have a problem.
I got all those steps then i describe above and it build and worked wihout any problemAnd of course i add mingw to PATH
-
-
Is libmysql.lib the static MySQL client lib ?
-
Yes you understood it well. The thing is, on windows, static libraries and import libraries have the same extension but don't work the same. And furthermore, you can't mix mingw and MSVC libraries like that.
Look at this "wiki entry":http://www.qtcentre.org/wiki/index.php?title=Building_the_QMYSQL_plugin_on_Windows_using_MinGW
For the steps to use MinGW
-
The same result(((...
BUT:
I found that i have MySQL drivers with official build of QT5.3.2))) I have no idea why i didn't see it in first time and spent much time trying to build this drivers)).
And firstly it didn't work too. Finally i put libmysql.dll into ...\Qt5.3.2\5.3\mingw482_32\bin and it works.!I think that problem with my own building of these drivers is that i have VS10, VS12, and MinGW compiler on one OS.... When i'll have free time, maybe in this everning i'll try to build it by mingw on virt. mach with Win7 without another compilers
Remark: i don't have an idea why - but reimp util from MINGW Utils works only in old version (0.3)
-
Hello All,
I do as following:
C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\mySQL\include" "LIBS+=C:\mySQL\lib\libmysql.lib" mysql.proC:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\mysql>mingw32-make
And go outpu like that:
C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\mysql>mingw32-make
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src/plugins/sqldrivers/mysql'
C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPT
release_shared" -I"........\mkspecs\win32-g++" main.cpp -o .moc\release_shared\main.moc
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_CAS
\QtCore\5.1.1\QtCore" -I".moc\release_shared" -I"........\mkspecs\win32-g++" -o .obj\release_shared\main.o mai
C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPT
release_shared" -I"........\mkspecs\win32-g++" ......\sql\drivers\mysql\qsql_mysql.cpp -o .moc\release_share
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_CAS
\QtCore\5.1.1\QtCore" -I".moc\release_shared" -I"........\mkspecs\win32-g++" -o .obj\release_shared\qsql_mysql
C:\Qt\Qt5.1.1\5.1.1\mingw48_32\bin\moc.exe -DUNICODE -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_EXCEPT
release_shared" -I"........\mkspecs\win32-g++" ......\sql\drivers\mysql\qsql_mysql_p.h -o .moc\release_share
g++ -c -pipe -fno-keep-inline-dllexport -O2 -std=c++0x -fno-exceptions -frtti -Wall -Wextra -DUNICODE -DQT_NO_CAS
\QtCore\5.1.1\QtCore" -I".moc\release_shared" -I"........\mkspecs\win32-g++" -o .obj\release_shared\moc_qsql_m
g++ -Wl,-s -shared -Wl,--out-implib,C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\plugins\sqldrivers\libqsqlmysql.a -o ......
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x17c): undefined reference tomysql_num_rows@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x1a7): undefined reference to
mysql_stmt_num_rows@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x23c): undefined reference tomysql_num_rows@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x259): undefined reference to
mysql_stmt_num_rows@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x29e): undefined reference tomysql_stmt_insert_id@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x2da): undefined reference to
mysql_insert_id@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x374): undefined reference tomysql_thread_end@0' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x37f): undefined reference to
mysql_close@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x7e8): undefined reference tomysql_character_set_name@4 .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x9c9): undefined reference to
mysql_errno@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x9e0): undefined reference tomysql_field_seek@8' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xa04): undefined reference to
mysql_field_seek@8'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xa0f): undefined reference tomysql_fetch_field@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xa4f): undefined reference to
mysql_fetch_field@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xa81): undefined reference tomysql_error@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xa90): undefined reference to
mysql_errno@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xc17): undefined reference tomysql_errno@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xc51): undefined reference to
mysql_stmt_error@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xc5e): undefined reference tomysql_stmt_errno@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xdda): undefined reference to
mysql_query@8'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0xf1a): undefined reference tomysql_query@8' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x105a): undefined reference to
mysql_query@8'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x1190): undefined reference tomysql_fetch_row@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x11d7): undefined reference to
mysql_stmt_fetch@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x1372): undefined reference tomysql_list_fields@12' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x13cd): undefined reference to
mysql_fetch_field@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x13dc): undefined reference tomysql_free_result@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x1ccc): undefined reference to
mysql_init@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x1e1e): undefined reference tomysql_real_connect@32' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x2031): undefined reference to
mysql_close@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x21ff): undefined reference tomysql_real_connect@32' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x2271): undefined reference to
mysql_set_character_set@8
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x2284): undefined reference tomysql_get_client_version@ .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x229d): undefined reference to
mysql_thread_init@0'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x240d): undefined reference tomysql_select_db@8' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x253f): undefined reference to
mysql_close@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x25eb): undefined reference tomysql_get_server_version@ .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x261b): undefined reference to
mysql_options@12'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x26ce): undefined reference tomysql_stmt_data_seek@12' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x26df): undefined reference to
mysql_stmt_fetch@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x2746): undefined reference tomysql_data_seek@12' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x2757): undefined reference to
mysql_fetch_row@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x29ad): undefined reference tomysql_fetch_lengths@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x38d4): undefined reference to
mysql_get_server_version@
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x3d73): undefined reference tomysql_list_tables@8' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x3dbd): undefined reference to
mysql_data_seek@12'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x3dc8): undefined reference tomysql_fetch_row@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x3fd0): undefined reference to
mysql_free_result@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x4172): undefined reference tomysql_next_result@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x419a): undefined reference to
mysql_store_result@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x41b4): undefined reference tomysql_field_count@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x420b): undefined reference to
mysql_affected_rows@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x42a2): undefined reference tomysql_fetch_field_direct@ .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x441c): undefined reference to
mysql_free_result@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x46bb): undefined reference tomysql_num_fields@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x47b2): undefined reference to
mysql_fetch_field@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x48a4): undefined reference tomysql_stmt_result_metadat .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x48d7): undefined reference to
mysql_free_result@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x48f8): undefined reference tomysql_next_result@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x4915): undefined reference to
mysql_stmt_close@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x493b): undefined reference tomysql_free_result@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x49f4): undefined reference to
mysql_store_result@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x4d52): undefined reference tomysql_real_query@12' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x4e43): undefined reference to
mysql_store_result@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x4e68): undefined reference tomysql_field_count@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x4eaa): undefined reference to
mysql_affected_rows@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x4f42): undefined reference tomysql_fetch_field_direct@ .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x5010): undefined reference to
mysql_field_count@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x50f6): undefined reference tomysql_stmt_prepare@12' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x510f): undefined reference to
mysql_stmt_param_count@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x5179): undefined reference tomysql_stmt_init@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x533a): undefined reference to
mysql_stmt_param_count@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x540c): undefined reference tomysql_stmt_reset@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x560d): undefined reference to
mysql_stmt_param_count@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x5626): undefined reference tomysql_stmt_execute@4' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x5785): undefined reference to
mysql_stmt_affected_rows@
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x57b5): undefined reference tomysql_stmt_bind_result@8' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x57d8): undefined reference to
mysql_stmt_store_result@4
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x5806): undefined reference tomysql_stmt_bind_result@8' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x584a): undefined reference to
mysql_stmt_param_count@4'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x5bca): undefined reference tomysql_stmt_bind_param@8' .obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x609d): undefined reference to
mysql_stmt_attr_set@12'
.obj/release_shared/qsql_mysql.o:qsql_mysql.cpp:(.text+0x6172): undefined reference to `mysql_real_escape_string@
c:/qt/qt5.1.1/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: .ob
collect2.exe: error: ld returned 1 exit status
Makefile.Release:80: recipe for target '........\plugins\sqldrivers\qsqlmysql.dll' failed
mingw32-make[1]: *** [........\plugins\sqldrivers\qsqlmysql.dll] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src/plugins/sqldrivers/mysql'
makefile:38: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2Pleas help me.
What Im doing wrong? -
Hi,
Looks like your not linking to the MySQL library.
LIBS+=-LC:/mySQL/lib -lmysql
should be the correct syntax
-
I know this is a very very old topic, but nonetheless somebody might benefit from this:
I was able to compile the mysql driver like this:
- Using Win10 home 64-bit
- Installed QT 5.15.0 64-bit (mingw)
- Installed mysql server 8.0.14 (located in C:\Program Files\MySQL\MySQL Server 8.0) and Connector C++ 8.0.15 (located in C:\Program Files\MySQL\Connector C++ 8.0. B. Both are 64-bit.
- Started QT and opened C:\Qt\5.15.0\Src\qtbase\src\plugins\plugins.pro
Modify mysql.pro like this (mind the forward slashes this was the last culprit why it didn't work here!):
TARGET = qsqlmysql INCLUDEPATH +='C://Program Files//MySQL//MySQL Server 8.0//include' DEPENDPATH += 'C://Program Files//MySQL//MySQL Server 8.0//include' LIBS += 'C://Program Files//MySQL//MySQL Server 8.0//lib//libmysql.lib' HEADERS += $$PWD/qsql_mysql_p.h SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp #QMAKE_USE += mysql OTHER_FILES += mysql.json PLUGIN_CLASS_NAME = QMYSQLDriverPlugin include(C:\Qt\5.15.0\Src\qtbase\src\plugins\sqldrivers\qsqldriverbase.pri)
- In QT Creator rightclick on the folder "mysql" and select "Build mysql"
- Make sure to do above in both release and debug
I found the files I needed in:
C:\Qt\5.15.0\Src\qtbase\src\plugins\build-sqldrivers-Desktop_Qt_5_15_0_MinGW_64_bit-Debug\plugins\sqldrivers
C:\Qt\5.15.0\Src\qtbase\src\plugins\build-sqldrivers-Desktop_Qt_5_15_0_MinGW_64_bit-Release\plugins\sqldrivers