[SOLVED]Trying to build mysql driver in Qt 5.1.0 and MySQL 5.6
-
[quote author="francescmm" date="1373443489"]Hi!
As SGalst has said you is that you must download the Qt sources. In addition, you must download the source code of MySQL from its webpage.
The next step is to open the mysql.pro, add the following lines:
@LIBS += mysql/path/lib/libmysql.lib
INCLUDEPATH += mysql/path/include@Then, you onyle have to compile in debug mode and in release mode. It provide you two files (I don't remember the exactly name) in both cases: [libqsqlmysqld.a, qsqlmysqld.dll] and [libqsqlmysql.a, qsqlmysql4.dll].
You have to copy them into the sqldrivers dir of Qt non-source path.[/quote]
when i am trying to make a mysql.pro by command "mingw32-make" it show me a lot of mistakes like: undefined reference to 'mysql_num_rows@4' and something like that.
after all it says:
c:/qt/qt5.1.0/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: .obj/release_shared/qsql_mysql.o: bad reloc address 0x4 in section `.data'
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.0/5.1.0/Src/qtbase/src/plugins/sqldrivers/mysql'
makefile:38: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2 -
It is because the folder you are including in both INCLUDEPATH and LIBS have not the necessary CPP files. Are you sure you have all the sources?
Try downloading: "MySQL Connector":http://dev.mysql.com/downloads/connector/c/
-
[quote author="francescmm" date="1373465557"]It is because the folder you are including in both INCLUDEPATH and LIBS have not the necessary CPP files. Are you sure you have all the sources?
Try downloading: "MySQL Connector":http://dev.mysql.com/downloads/connector/c/[/quote]
yes, I am sure that i have all sources, should I setup environment variables???
may be it is because i have win8 x64 but my mingw x32 and qt5.1.0 x32??? -
Thanks very much everybody! The problem is solved :)
-
Great !
Then don't forget to update the thread's title to solved, so other forum users may know a solution has been found :)
-
Hello,
It would have been nice to tell us how you solved your problem koresaram777.
Indeed, I follow every indication, download the C connector sources archives and then the C++ one, but still, I can't compile the plugin. There is no C++ file into those archive (only headers files).
I did some research but every time I have got a topic that says a different way. And I always still have those error messages:
undefined references to mysql_num_rows@4, mysql_stmt_num_rows@4, etc.
My computer is a 32bits so I only used (and download) the tools for 32bits. I say that because main of forum topic says that the problème come when using 64bits sources when the installed version of MySQL is 32bits.
If someone can help me. Thanks.
-
[quote author="Vinorcola" date="1380787942"]Hello,
It would have been nice to tell us how you solved your problem koresaram777.
Indeed, I follow every indication, download the C connector sources archives and then the C++ one, but still, I can't compile the plugin. There is no C++ file into those archive (only headers files).
I did some research but every time I have got a topic that says a different way. And I always still have those error messages:
undefined references to mysql_num_rows@4, mysql_stmt_num_rows@4, etc.
My computer is a 32bits so I only used (and download) the tools for 32bits. I say that because main of forum topic says that the problème come when using 64bits sources when the installed version of MySQL is 32bits.
If someone can help me. Thanks.[/quote]
when you download the c connector, you need to install it, after installation create the empty folder in c disk, after this just copy all you files from C:\Program Files\MySQL\Connector C++\ to your new folder, and rename this folder for example mySQL, but do it without spaces. and aflter that when you compile reference to that folder which you created before and that's all :)
-
[quote author="Vinorcola" date="1380803548"]I did what you said, but have still have the same error. Can someone help me? Or send me the compile plugin?
Thanks[/quote]
give your email and what qt version do you have?
-
Hi,
I've got some problems to compile Mysql driver, is something obvious for you ?
@cd C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\mysql
set mysql="C:\\PROGRA~1\\MySQL\\MYSQLS~1.6"
qmake "INCLUDEPATH+=%mysql%\include\" "LIBS += -L %mysql%\lib\libmysql.lib" -o Makefile mysql.pro
mingw32-make@
@g++ -Wl,-s -shared -Wl,--out-implib,C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\plugins\sqldr
ivers\libqsqlmysql.a -o ........\plugins\sqldrivers\qsqlmysql.dll .obj/releas
e_shared/main.o .obj/release_shared/qsql_mysql.o .obj/release_shared/moc_qsql_my
sql_p.o -llibmysql -LC:\Qt\Qt5.1.1\5.1.1\mingw48_32\lib -lQt5Sql -lQt5Core
c:/qt/qt5.1.1/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../..
/i686-w64-mingw32/bin/ld.exe: cannot find -llibmysql
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/s
qldrivers/mysql'
makefile:38: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2@ -
@ "LIBS += -L %mysql%\lib\libmysql.lib"@
That's your problem, -L is to give a path not a library name
-
Thanks for your post's!
I got an issue if I want to build my driver. I'm using qt 5.3 and mysql 5.6 (mysql-5.6.20-win32).
I added mysql.pro to qt creator and add the following two lines to the .pro file:
@
LIBS += C:/mysql/mysql-5.6.20-win32lib/libmysql.lib
INCLUDEPATH += C:/mysql/mysql-5.6.20-win32/include
@I got the following errors if i want to compile the mysql project:
C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'fd'
C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht untersttzt.
C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'fd'
C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht untersttzt.
C:\work\build\qt5\qtbase\src\sql\drivers\mysql\qsql_mysql.cpp:44: error: C1083: Datei (Include) kann nicht ge”ffnet werden: "QtSql/private/qsqldriver_p.h": No such file or directory
Many thanks for your help!
-
Hi and welcome to devnet,
Did you first build Qt 5 yourself ?
-
Hi SGaist,
yes I built qt5 by my self. I also tried to build the drivers with the following commands (see http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows):
cd C:\work\build\qt5\qtbase\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\mysql\mysql-5.6.20-win32\include" "LIBS+=C:\mysql\mysql-5.6.20-win32\lib\libmysql.lib" mysql.pro
mingw32-make
If I do the "mingw32-make" command I got the following errors:
C:\work\build\qt5\qtbase\src\plugins\sqldrivers\mysql>mingw32-make
mingw32-make -f Makefile.Release all
mingw32-make[1]: Entering directory 'C:/work/build/qt5/qtbase/src/plugins/sqldri
vers/mysql'
Makefile.Release:65: *** missing separator. Stop.
mingw32-make[1]: Leaving directory 'C:/work/build/qt5/qtbase/src/plugins/sqldriv
ers/mysql'
mingw32-make[1]: Leaving directory 'C:/work/build/qt5/qtbase/src/plugins/sqldriv
ers/mysql'
Makefile:40: recipe for target 'release-all' failed
mingw32-make: *** [release-all] Error 2 -
You're on windows either escape the backslashes or since you are using Qt use the unix notation i.e. forward slashes
-
I know you are, and I already wrote the options you have:
- escape the \ so in practice use \
- Since you are using Qt use /
Second option is cleaner.
-
Sorry for that stupid questions. I'm using the QT 5.4.0 64-bit for Desktop (MSVC 2013) command line.
I got the same errors if I'm setting the paths like:
qmake "INCLUDEPATH+=C:\mysql\mysql-5.6.20-win32\include" "LIBS+=C:\mysql\mysql-5.6.20-win32\lib\libmysql.lib" mysql.pro
or:
qmake "INCLUDEPATH+=C:/mysql/mysql-5.6.20-win32/include" "LIBS+=C:/mysql/mysql-5.6.20-win32/lib/libmysql.lib" mysql.pro
or does it mean that I have to set the slashes in the Makefile.Release instead of \ to /
Many thanks.
-
Ok, i was googling the problem. I get the error in the Makefile.Release in line 65:
@{......\sql\drivers\mysql}.cpp{.obj\release}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo.obj\release\ @<<
$<
<<@I get the error in line "<<"
I add before "<<" a tab, so "\T<<". After I fired the mingw32-make command I still got the same problem. It seems to me that the Make.Release and Make.Debug files are generated each time if I do the mingw32-make command.
Where can I set this behavior?
-
First thing to do is to delete that folder content and restart