Solved Building Mysql-Plugin on OS X with Qt 5.9.1 fails
-
Hello forum users,
I'm trying to build the MySql-Plugin on OS X. mysql headers are installed, I've also compiled the mysql drivers for Qt 5.7.1 on the same machine about a year ago. I haven't uninstalled any mysql-dev files since then.
My mysql-Installation is here:/usr/local/mysql/
In it, I've got a 'lib' folder and an 'include' folder
Inside the 'lib' folder, I've got among others a 'libmysqlclient.20.dylib' and 'libmysqlclient_r.dylib'
In the 'include' folder there is a bunch of header files.
Now, trying to compile my MySql-Plugin with these commands:
cd /Users/NAME/Qt/5.9.1/Src/qtbase/src/plugins/sqldrivers/mysql /Users/NAME/Qt/5.9.1/clang_64/bin/qmake "INCLUDEPATH+=/usr/local/mysql" "LIBS+=-L/usr/local/mysql/ -lmysqlclient_r" mysql.pro
Reveales this error:
IBS+=-L/usr/local/mysql -lmysqlclient_r" mysql.pro Project ERROR: Library 'mysql' is not defined.
Edit: Meanwhile, I've found out, that the error comes from this line in mysql.pro:
QMAKE_USE += mysql
But mysql.h is present in /usr/local/mysql/include
End edit.Trying to configure my source on top level with -sql-mysql leads to another error:
./configure -sql-mysql -I/usr/local/mysql ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
I'm on a freshly installed Src tree, just downloaded from the Qt server.
Any hints how to resolve any of these errors?
Is there anything wrong with my include paths? -
Replying my own question:
The following tweaks worked for compiling the libs:
Change mysql.pro to:TARGET = qsqlmysql HEADERS += $$PWD/qsql_mysql_p.h SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp LIBS += -L/usr/local/mysql/include #QMAKE_USE += mysql OTHER_FILES += mysql.json PLUGIN_CLASS_NAME = QMYSQLDriverPlugin include(../qsqldriverbase.pri)
Then run qmake like this:
/Users/daniel/Qt/5.9.1/clang_64/bin/qmake "INCLUDEPATH+=/usr/local/mysql" "LIBS+=-L/usr/local/mysql/lib -lmysqlclient" "INCLUDEPATH+=/usr/local/mysql/include" mysql.pro
make and install:
make make install
My Application is still not using the Mysql-driver, but that the next step, I presume.
Edit: make install line added