1

I tried a lot of things I read on documentations or tutorials... But I still can't cross-compile Qt with the MySQL library driver. Story begins:

I have to cross-compile Qt from Linux to Windows (32bits) using MinGW (i686-w64-mingw32- prefix to be precise). I downloaded qtbase-opensource-src-5.9.4 and started to work like that:

$ ./configure -prefix [...]/qt-5.9.4 -xplatform win32-g++ -device-option CROSS_COMPILE=/usr/bin/i686-w64-mingw32- -opengl desktop -no-sql-odbc -sql-sqlite -enable-shared -nomake examples -nomake tests -release

And it worked. Then, make and make install worked too. But I figured out that there was only the SQLite ".dll" in the plugins/sqldrivers repository. So I tried to compile the MySQL driver and... How can I do that?? If I add -sql-mysql to my ./configure ... call, I have to following error:

ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.

I downloaded MySQL library from the official website to get mysql-5.7.21-win32.zip. But how to link it with qtbase sources? Adding MYSQL_INCDIR=[...]/mysql-5.7.21-win32/include and MYSQL_LIBDIR=[...]/mysql-5.7.21-win32/lib or just MYSQL_PREFIX=[...]/mysql-5.7.21-win32 to my ./configure ... command results to the same error message.

Any idea please?

EDIT:

I tried to compile the driver like that (with the qmake I built previously):

$ cd qtbase-opensource-src-5.9.4/src/plugins/sqldrivers/mysql
$ [/*prefix of my previous build*/]/qt-5.9.4/bin/qmake .

And the result is:

Project ERROR: Library 'mysql' is not defined.
2
  • Did you cross-compile MySQL as well?
    – JvO
    Mar 6, 2018 at 15:51
  • @JvO No. But I think it should works because this lib contains the .dll/.lib, the headers and some useless .exe in my case.
    – N0un
    Mar 6, 2018 at 17:04

2 Answers 2

1

Ok everyone, I found the solution: do a clean checkout or add -recheck-all to the ./configure command when you want to add a lib like MySQL in my case. Easy isn't it? To make it clear, here is the command I used:

./configure -prefix [...] -xplatform win32-g++ -device-option CROSS_COMPILE=/usr/bin/i686-w64-mingw32- -opengl desktop -no-sql-odbc -sql-sqlite -plugin-sql-mysql MYSQL_PREFIX=[...] -enable-shared -nomake examples -nomake tests -release -recheck-all

That was just a refresh problem, but I prefer to let this answer because it's pretty hard to realize.

0

Instead of what you tried in your EDIT, should I think be:

$ cd qtbase-opensource-src-5.9.4/src/plugins/sqldrivers
qmake -- MYSQL_PREFIX= [...]/mysql-5.7.21-win32/include
4
  • Thank you for your answer but it produces the same result: Project ERROR: Library 'mysql' is not defined.
    – N0un
    Mar 6, 2018 at 17:02
  • @N0un Do you have MySQL header files and libmysqlclient.so under [...]/mysql-5.7.21-win32 Mar 6, 2018 at 17:05
  • @N0un, header files are usually under ../include , as I updated my answer Mar 6, 2018 at 17:24
  • Tks for your answer but... If I launch this qmake in qtbase-opensource-src-5.9.4/src/plugins/sqldrivers, there is no error message but the Makefile doesn't contains any directive to produce MySQL (only sub-sqlite...). If I launch it in sub directory /mysql it produces the same error message than in my EDIT.
    – N0un
    Mar 7, 2018 at 8:16

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.