Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
install mysql driver for Qt5.12.4
I was attempting to install the mysql driver for Qt5.12.4 on Ubuntu 18.04 64-bit. Attempting to run
gives me the following error:
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
It appears that there are dependencies I don't have but how to know which ones they are?
Google has not provided an answer for me.
Thanks so much in advance!
how to know which ones they are?
Add -v parameter to configure call and take a closer look at build log.
You probably did not install mysql-dev package.
Thanks for your response.
I have the following installed (ubuntu 18.04 repository):
but still getting the above error.
@montanaviking I think you need libmysqlclient-dev not libmysqld-dev.
And as I suggested adding -v parameter to configure can give you more information about what is missing.
I'll try your suggestions. However, I was able to get the mysql library to load via:
- Installed the Qt5.12.4 package again in another directory, i.e. /opt/QtLTS
- ran ./configure -sql-mysql in the /opt/QtLTS/5.12.4/Src directory (as root)
The above took several hours.
New code was then installed in my /usr/local directory instead of the original Qt install directory. Apparently, I could not get Qtcreator to load libraries from the new /usr/local/Qt5.12 directory as it kept trying to use the /opt/Qt directory even though I'd edited the kits in Qtcreator to make the /usr/local/Qt-5.12.4 directory the default.
I ended up just copying the freshly-built libqsqlmysql.so file from the /usr/local/Qt-5.12.4/plugins/sqldrivers directory to /opt/QtLTS/5.12.4/gcc_64/plugins/sqldrivers
and my code loaded the mysql library and ran!
@montanaviking You can specify installation directory when calling configure.
In QtCreator you need to add your new Qt installation under Options/Kit and then Qt versions (you simply select qmake from your new Qt).
I'm sure I'm doing something wrong, but oddly, pointing Qtcreator kit at the directory of the newly-built Qt 5.12.4 installation (/usr/local/Qt-5.12.4) didn't work and QtCreator still kept trying to compile against the precompiled ( /opt/QtLTS/5.12.4) Qt directory and its libraries. I had to add the newly-built libqsqlmysql.so to the /opt/QtLTS/5.12.4/gcc_64/plugins/sqldrivers to properly compile my project. Checking the compiler output showed that in spite of making the /usr/local/Qt-5.12.4 the default kit, Qtcreator kept using the /opt/QtLTS/5.12.4/ installation and therefore could not find the mysql library until I added it.
I will try to set my installation directory (instead of the default) next time I compile Qt - Thanks,
By (I know this is a separate questions) the way, when I tried compiling Qt 5.12.4 to produce static libraries, by using the -static option with ./configure, i.e. ./configure -static, this command gave an error that -static is not a valid option. Did the Qt company somehow disallow static compiling? This is strange to me because all the documentation had me believe that ./configure -static is a valid command?
Thanks again for your advice!
@montanaviking I actually wasn't talking about QtCreator but about providing installation directory to the configure script, so make install puts the libs into that directory.
To add another Qt installation in QtCreator you need to add it in Options - select its qmake there. Then create a Kit there you select this Qt version.
-static is still a valid parameter for configure.
Which configure exactly did you call? The top one?