[SOLVED]mysql.pro build errors
-
Hi! I wanted to build mysql.pro to have an sqldriver. I downloaded Qt 5.1.1 MinGW (already built) so I don't have source files. I downloaded them and extracted mysql folder. Then I opened mysql.pro, after editing it like this:
@
TARGET = qsqlmysql
SOURCES = main.cpp
include(../../../sql/drivers/mysql/qsql_mysql.pri)
INCLUDEPATH += "C:\Program Files\MySQL\MySQL Server 5.6\include"
LIBS += "C:\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.lib"
include(../qsqldriverbase.pri)
@Then I'm trying to build the project with MinGW but there are following error:
C:\Qt\5.1.1\mingw48_32\include\QtCore\qglobal.h:655: ошибка: expected constructor, destructor, or type conversion before 'enum'
enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, LINE) = sizeof(QStaticAssertFailure<!!(Condition)>)}
^
C:\Qt\5.1.1\mingw48_32\include\QtCore\qglobal.h:656: in expansion of macro 'Q_STATIC_ASSERT'
#define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
^
C:\Qt\5.1.1\mingw48_32\include\QtCore\qplugin.h:132: in expansion of macro 'Q_STATIC_ASSERT_X'
Q_STATIC_ASSERT_X(false, "Old plugin system used")
^
C:\qt-everywhere-opensource-src-4.8.5\src\plugins\sqldrivers\mysql\main.cpp:80: in expansion of macro 'Q_EXPORT_PLUGIN2'
Q_EXPORT_PLUGIN2(qsqlmysql, QMYSQLDriverPlugin)
^
The circumflexes are under 'sizeof' in the first error and in the beginning of the line in the all other lines.
I'm on Win8x64, QtCreator 2.8.1, Qt 5.1.1 MinGW 32bit. The sources I've downloaded is 'qt-everywhere-opensource-src-4.8.5'. Please, help!) -
Hi,
The problem you are having is that you are trying to build the mysql plugin from Qt 4.8.5 with Qt 5.1.1. That won't work.
You should also consider getting 5.2.1, it's more up to date.
On a side note, you should consider moving (as in reinstalling) mysql in a path without spaces. Spaces are a known sources of problems on windows.
-
Hi! I've downloaded Qt 5.2.1 sources and to avoid spaces in paths replaced lib and include folders from mysql original destination to C:\MySQL_lib\lib, and C:\MySQL_lib\include respectively. Then I opened mysql.pro from the new sources and added these two lines to it:
@INCLUDEPATH += "C:\MySQL_lib\include"
LIBS += "C:\MySQL_lib\lib\libmysql.lib" @
After trying to build there was one qmake error as follows:Project ERROR: addExclusiveBuilds() requires at least two arguments
-
Are you trying to build the code from 5.2.1 with 5.1.1 ?
-
I'm sorry. My bad. I've forgotten that I have 5.1.1. Later I've got hold of 5.1.1 src and used them. mysql.pro:
@TARGET = qsqlmysqlSOURCES = main.cpp
OTHER_FILES += mysql.json
include(../../../sql/drivers/mysql/qsql_mysql.pri)PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
include(../qsqldriverbase.pri)
INCLUDEPATH += C:\MySQL_lib\include
LIBS += C:\MySQL_lib\lib\libmysql.lib
@
Didn't edit anything else at all. Then, trying to rebuild, I get errors as follows:
c:/qt/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
Thus, the lib cannot be found. And if I add not new paths, but default, how they were with the MySQL server from the start I get the same error. -
P.S. I've always had problems with linking with libs etc.)
-
Please use forward slashes for paths.
Also try replacing your LIBS line with
@LIBS += -LC:/MySQL_lib/lib@
-
Hi! Now it doesn't say it can't find a lib, but it obviously doesn't find it anyway. there are no "can't find" errors, but there are 107 "undefined reference to..." errors, all of them about some mysql functions. And all of them in qsql_mysql.cpp file(
-
What does "C:\MySQL_lib\lib" contain ?
-
I have removed and downloaded the most fresh MySQL. So now libs are located this way: C:\MySQL\MySQL_Server_5.5\lib and the mysql.pro looks like this:
@TARGET = qsqlmysqlSOURCES = main.cpp
OTHER_FILES += mysql.json
include(../../../sql/drivers/mysql/qsql_mysql.pri)PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
include(../qsqldriverbase.pri)LIBS += -LC:/MySQL/MySQL_Server_5.5/lib
INCLUDEPATH += C:/MySQL/MySQL_Server_5.5/include
@
Errors are absolutely the same. "C:/MySQL/MySQL_Server_5.5/lib" directory contains:
debug (folder)
plugin (folder)
libmysql.dll
libmysql.lib
mysqlclient.lib -
May it be, that libmysql I have downloaded is, say, x64 or something of the sort, so that compiler just is not compatible with it?
-
Hi, yes - if you try to use the 64-bit MYSQL with the mingw 32-Bit you won't succeed
-
The thing is, that I don't really know how to find out)
-
I suggest you have a look at this short step-by-step tutorial:
"Qt5 MYSQL":http://seppemagiels.com/blog/create-mysql-driver-qt5-windows -
Yes, thanks, I'm already reading and downloading mysql-5.6.16-win32.zip
-
Great thanks to everybody and especially to Samuel! Everything works!)
-
Hi, that's fine - good news!
Please mark your thread as [SOLVED] by editing the first post -
What have you change, that you get rid off this error?