Qt 5.10.0 building mysql driver on Windows
-
Hi,
Despite the tutorial in Qt Documentation, I cannot build the mysql driver.
I've already search on google and on this forum but none solve my problem.When I try to run the following :
set mysql=C:\\PROGRA~2\\MySQL\\MYSQLS~1.7 qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" mysql.pro
I got this error message :
Project ERROR: Library 'mysql' is not defined.
I've installed mysql server in x86, mysql connector C++ in x86 and mysql connector C in x86.
I already reinstalled the entire Qt Creator.Now I don't know what to do to make it work :(.
Please help me :).
-
What compiler are you using?
I am not sure about your double backslashes. Never tried that way in windows.
@EagleWatch said in Qt 5.10.0 building mysql driver on Windows:
set mysql=C:\\PROGRA~2\\MySQL\\MYSQLS~1.7
I would not use the short path version here, even though it should work. Also under windows the forward slashes (only single then) can be used. Typically less hazzle.
qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" mysql.pro
I would simply copy the .pro file into a new one (e.g. newmysql.pro) and add the statements. That makes all a bit clearer.
TARGET = qsqlmysql INCLUDEPATH += <full path here>/include LIBS += -L<full path here>/lib LIBS+= -lmysql 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(../qsqldriverbase.pri)
Note there are in LIBS statement prefixes "-L" and "-l" (uppcase and lowercase 'L')
See for some details here -
Thx for your reply.
I'm using mingw32.
So, I've tried with single forward slash, and the result is the same (Project ERROR: Library 'mysql' is not defined.).
I also tried with a copy of mysql.pro and added the statement you suggested.The error is still the same.
I don't know why the library 'mysql' cannot be used :(.
-
You can add
message("LIBS " $$LIBS)
to get the output what you have actually in your LIBS statement. Are you sure that the path you are using is ok?
-
Hi,
IIRC, with the latest versions of Qt, you have to call qmake one level above first, and the in the folder of the driver you are interested in.
-
Are still using this follwing commands?
set mysql=C:\\PROGRA~2\\MySQL\\MYSQLS~1.7 qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" mysql.pro
@koahnig said in Qt 5.10.0 building mysql driver on Windows:
TARGET = qsqlmysql INCLUDEPATH += <full path here>/include LIBS += -L<full path here>/lib LIBS+= -lmysql 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(../qsqldriverbase.pri)
Note there are in LIBS statement prefixes "-L" and "-l" (uppcase and lowercase 'L')
See for some details hereThis was meant as substitute of your previous mysql.pro
You would have to use:
qmake newmysql.pro
However, you have to replace <full path here> with your actual full path.
-
No, I'm not using the first command anymore.
I used :
qmake newmysl.pro
I had a mistake in message command, that's why it didn't work before.
So, here is what I get now :Project MESSAGE: LIBS -LC:\Program Files (x86)\MySQL\MySQL Server 5.7/lib -lmysql Project ERROR: Library 'mysql' is not defined.
I have replaced <full path> with my path ;).
-
OK, change to
INCLUDEPATH += "C:/Program Files (x86)/MySQL/MySQL Server 5.7/include" LIBS += -L"C:/Program Files (x86)/MySQL/MySQL Server 5.7/lib"
AFAIK qmake is not happy about backslashes. You use them only for continuation lines.
-
Here is the result :
Project MESSAGE: LIBS -LC:/Program Files (x86)/MySQL/MySQL Server 5.7/lib -lmysql Project ERROR: Library 'mysql' is not defined.
I've also tried to use the configure script with :
configure -sql-mysql
But the result was :
Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... yes PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no
It seems that mysql is no recognized :(.
-
Might be a stupid question, but are you a 100% positive that the library stump is really at that given location?
Also the INCLUDEPATH and LIBS statement in .pro file requires " because of the spaces in the path names. However, you can basically copy the folders "include" and "lib" into a folder without spaces. That gets you rid of the ambiguities with the proper syntax of using "
When copying the folders from "C:/Program Files (x86)/MySQL/MySQL Server 5.7/include" to "c:/mysqltmp/include" and
"C:/Program Files (x86)/MySQL/MySQL Server 5.7/lib" to "c:/mysqltmp/lib" for instance you can useTARGET = qsqlmysql INCLUDEPATH += c:/mysqltmp/include LIBS += -Lc:/mysqltmp/lib LIBS += -lmysql 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(../qsqldriverbase.pri)
Did you try to follow @SGaist 's advice?
-
Yes, I'm pretty sure.
Just in case, you can see what are the libs in the path :11/02/2018 13:42 <DIR> . 11/02/2018 13:42 <DIR> .. 09/12/2017 09:00 4 165 632 libmysql.dll 09/12/2017 09:00 27 538 libmysql.lib 09/12/2017 09:00 18 174 230 mysqlclient.lib 11/02/2018 13:42 <DIR> plugin
I tried to copy the include and libs folders into a folder without spaces (C:/mysql/include and C:/mysql/lib)
So I changed it in the newmysql.pro file.
However the error is still here.I've removed completely my MySQL installation and installed a new one with the version 5.6.39 instead of version 5.7.21 because I've checked that Qt team has tested it on 5.6.11 (version I cannot find on the official mysql website).
But the error is still here.I've followed @SGaist advice as mentionned below, but I've still the error :(.
Maybe I cannot build the MySQL plugin under Qt Version 5.10, so I've to change to another database ?
-
Well the question is also if you have to build it all. With pre-builts it is included.