PDA

View Full Version : compile mySQL plugin - mysql_config not found



stryga42
15th November 2022, 15:57
Dear all,
I have to add mySQL / MariaDB support in an old 5.15.2 installation. As explained in https://doc.qt.io/qt-5/sql-driver.html#qmysql I have to compile the plugin myself. The problem is, that the qmake step does not recognize the mariaDB installation:

user:/opt/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers$ qmake -- MYSQL_INCDIR="/usr/include/mariadb" MYSQL_LIBDIR="/lib/x86_64-linux-gnu"

Running configuration tests...
Done running configuration tests.

Configure summary:

Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... no

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/opt/Qt/5.15.2/gcc_64'.

Same result if I try
qmake -- MYSQL_PREFIX=/usr/include/mariadb . I am quite sure that mariaDB IS installed:


user:/opt/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers$ ls /usr/include/mariadb/mysql*
/usr/include/mariadb/mysql_com.h /usr/include/mariadb/mysqld_error.h /usr/include/mariadb/mysql.h /usr/include/mariadb/mysql_version.h

/usr/include/mariadb/mysql:
client_plugin.h plugin_auth_common.h plugin_auth.h
user:/opt/Qt/5.15.2/Src/qtbase/src/plugins/sqldrivers$ ls /lib/x86_64-linux-gnu/libmysql*
/lib/x86_64-linux-gnu/libmysqlclient.so.21 /lib/x86_64-linux-gnu/libmysqlclient.so.21.2.31 /lib/x86_64-linux-gnu/libmysqlservices.a

It seems that qmake does not find any of the config-tests as config.log says - pay attention to line 8, 11, ... which says mysql_config not found.


Command line:
Global lib dirs: [/home/qt/openssl-1.1.1g/lib] [/usr/lib/gcc/x86_64-linux-gnu/9 /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib]
Global inc dirs: [/home/qt/openssl-1.1.1g/include] [/usr/include/c++/9 /usr/include/x86_64-linux-gnu/c++/9 /usr/include/c++/9/backward /usr/lib/gcc/x86_64-linux-gnu/9/include /usr/local/include /usr/include/x86_64-linux-gnu /usr/include]
loaded result for library config.sqldrivers.libraries.db2
...
loaded result for library config.sqldrivers.libraries.mysql
Trying source 0 (type mysqlConfig) of library mysql ...
mysql_config not found.
=> source produced no result.
Trying source 1 (type mysqlConfig) of library mysql ...
mysql_config not found.
=> source produced no result.
Trying source 2 (type mysqlConfig) of library mysql ...
mysql_config not found.
=> source produced no result.
Trying source 3 (type mysqlConfig) of library mysql ...
mysql_config not found.
=> source produced no result.
Trying source 4 (type inline) of library mysql ...
mysql.h not found in [] and global paths.
=> source produced no result.
Trying source 5 (type inline) of library mysql ...
=> source failed condition 'config.win32'.
Trying source 6 (type inline) of library mysql ...
=> source failed condition 'config.win32'.
Trying source 7 (type inline) of library mysql ...
mysql.h not found in [] and global paths.
=> source produced no result.
Trying source 8 (type inline) of library mysql ...
mysql.h not found in [] and global paths.
=> source produced no result.
test config.sqldrivers.libraries.mysql FAILED
loaded result for library config.sqldrivers.libraries.oci
...


I already removed the sources and re-installed them using the Maintenance tool. Did not help.

Where should these tests be located?
Can I force the mySQL build somehow?
I think the include path has to point to mysql.h - correct?



Any hint highly welcome.

Ginsengelf
16th November 2022, 08:57
Hi, can you execute mysql_config directly from a command line?
On my openSUSE system it is part of the libmariadb-devel package, maybe you are simply missing some package?

Ginsengelf

stryga42
17th November 2022, 17:16
Good hint, thanks.
On ubuntu 20.04 the package seem be called libmariadb-dev. So yes, libmariadb-dev and libmariadbclient-dev are installed.
Where is mysql_config on your system? Somehow I can't find it at all...

Added after 7 minutes:

UPDATE:
A very ugly (although working) workaround is to tweak the mysql.pro in the mysql subfolder.
I removed the QMAKE_USE += mysql and added INCLUDEPATH and LIBS pointing to the appropriate places. And viola it compiles, installs and is found at runtime.
Still I would be highly interested in a clean solution.

Ginsengelf
18th November 2022, 07:17
Hi,

on my system it's in /usr/bin/mysql_config
According to https://packages.ubuntu.com/search?suite=focal&mode=filename&searchon=contents&keywords=mysql_config
it should be part of libmysqlclient-dev on Ubuntu 20.04 (or libmariadb-dev-compat).

Ginsengelf

stryga42
30th November 2022, 19:53
Thanks for looking it up. Yes, you are right it is exactly there.
I think I found the problem. Something screwed up the qtchooser setup and qmake executed in a partly invalid Qt environment. A simple export QT_SELECT="qt5.15.2" did the job. Now MySql (aka mariaDB) is recogized.

Added after 4 minutes:

Additional comment: I tried the same thing on another Ubuntu 20.04 machine with Qt5.15.2. There compile did work there but during runtime the plugin thinks that the DB does not support transactions. Very weired... I'll close this thread anyway. Thank's for your effort! (And, please Qt team, provide a precompiled mariaDB plugin :-) )