Unsolved QMYSQL Driver not loaded but available
-
I believe I am making progress. Found a good resource. Here's a more open-ended question: how would one know they needed to compile Qt from source code in order to use MySQL? It's definitely not spelled out anywhere in the documentation that I could find, and it's taken me the better part of a week (off and on) to troubleshoot it. Is this just a weird edge-case that doesn't happen often, or is the standard way that all development packages should be installed to ensure dependencies are met?
-
OK, I followed the instructions here and it looks like everything built correctly. However, when I now try to build the plugin in the terminal using:
seth@seth-XPS-L521X:~/qt-everywhere-src-5.10.0/qtbase/plugins/sqldrivers$ qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
I get the message:
Cannot find file: mysql.pro.
Thoughts?
-
@SethTales Is there mysql.pro in ~/qt-everywhere-src-5.10.0/qtbase/plugins/sqldrivers ? I guess it is in mysql subdirectory?
-
No there is not. In fact, I can't find a MySQL.pro file anywhere on my system. Is this a file I need to create?
-
Do I need to explicitly call qmake from the qt-everywhere-src-5.10.0 folder?
-
It should be in
qtbase/src/plugins/sqldrivers/mysql/
. If not then you should consider re-downloading the sources. -
It is not there. How do I ensure that it is there when I re-download the sources?
-
- Download the sources
- Un-compress the archive
- Take a look in the folder mentioned before
-
OK, but what if the mysql.pro file is not in the folder above? I ask because since I will be downloading the same archive as I used earlier, that has led me to the problem of the mysql.pro file not being there. I assume this will be the case again. If this is the case, how to I obtain sources that contain the proper files for making the plugin with mysql?
-
Where did you get the sources from ?
-
I downloaded the tar.xz archive from https://www1.qt.io/offline-installers/
-
@SethTales said in QMYSQL Driver not loaded but available:
Here's a more open-ended question: how would one know they needed to compile Qt from source code in order to use MySQL?
Just to be clear: You do not have to compile Qt from source code to use MySQL (or almost anything else). You have to because you are choosing the latest Qt release, 5.10.
Instead, you are using Ubuntu 16.04, you could accept the pre-compiled packages, available through standard
apt-get
, for the version of Qt that was current at the time 16.04 was released. I think that was Qt 5.5., BTW.For example, I use Ubuntu 17.04 now, and the
apt-get
package gives me Qt 5.7.1. Similarly, I use whatever the version of MySQL was for 17.04. I have not fetched a line of source code or done any compiling at all. And thankful for that!When 18.04 comes out, I will do same, upgrading to whatever versions of Qt & MySQL are available then through
apt-get
.So it in part depends on whether you need the latest version of Qt or not.
-
@JonB Thank you for the clarification! That makes a ton more sense. I was beginning to wonder why connecting to a database is seemingly giving so many people so much trouble!
I've actually figured out a different way to solve the problem by using C++ MySQL Connector libraries provided by Oracle, and have gotten it working in my application! I will also try using the Qt and MySQL versions provided by my Ubuntu release and see how that goes.