Qt 5.10.0 building mysql driver on Windows
-
wrote on 10 Feb 2018, 13:14 last edited by
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 :).
-
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 :).
wrote on 10 Feb 2018, 14:32 last edited byWhat 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 -
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 herewrote on 10 Feb 2018, 17:08 last edited byThx 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 :(.
-
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 :(.
wrote on 10 Feb 2018, 18:35 last edited byYou 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.
-
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?
wrote on 10 Feb 2018, 21:13 last edited by EagleWatch 2 Nov 2018, 13:56 -
wrote on 10 Feb 2018, 22:01 last edited by
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.
-
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.
wrote on 10 Feb 2018, 22:36 last edited by EagleWatch 2 Oct 2018, 22:51No, 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 ;).
-
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 ;).
wrote on 10 Feb 2018, 23:10 last edited byOK, 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.
-
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.
wrote on 10 Feb 2018, 23:23 last edited byHere 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 :(.
-
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 :(.
wrote on 11 Feb 2018, 10:40 last edited by koahnig 2 Nov 2018, 10:51Might 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?
-
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?
wrote on 11 Feb 2018, 13:23 last edited byYes, 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 ?
-
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 ?
wrote on 11 Feb 2018, 13:59 last edited byWell the question is also if you have to build it all. With pre-builts it is included.
-
Well the question is also if you have to build it all. With pre-builts it is included.
wrote on 11 Feb 2018, 14:16 last edited by
10/14