[Solved] Unable to access low-level MySQL drivers in 5.3.1
-
I have a Windows-based application created with Qt 4.7 that uses MySQL database. Works well. The application can (optionally) use an embedded version of MySQL. That also works well. That bit of code uses the low-level MySQL drivers to connect to the DB. All other DB access code is the same.
Now I'm trying to upgrade Qt to 5.3.1 and having problems with access to the MySQL low-level stuff in Qt.
I build my version of Qt from sources.
For my shared debug version of Qt 5.3.1 I used the following steps from a CMD shell. Note the 'CD' is actually 'percent CD percent' but I can't get this viewer to display those characters correctly...
@
cd c:\programs\qt (this directory contains the '5.3.1-base'
source directory)
mkdir 5.3.1-dd
cd 5.3.1-dd
..\5.3.1-base\configure.bat -prefix CD\qtbase -debug -shared ^
-qt-sql-mysql -no-compile-examples -qt-sql-odbc ^
-opengl desktop -qt-style-windowsvista ^
-no-rtti -no-icu -mp -saveconfig dd ^
-I C:\Programs\MySQL\MySQLServer5.1\include ^
-L C:\Programs\MySQL\MySQLServer5.1\lib\opt
@That builds.
Now the code that accesses the low-level MySQL drivers (needed for the embedded version) tries to include:
@
#include <qsql_mysql.h>
#include <mysql.h>
@Unfortunately, my '5.3.1-dd' structure doesn't contain the 'qsql_mysql.h' file anywhere.
I see there's a 'qsql_mysql_p.sql' file in '5.3.1-base\qtbase\src\sql\drivers\mysql'.
Hmmmm. Is support for accessing the low level MySQL drivers still available in 5.3?
-
Hi and welcome to devnet,
Yes it is, it's qsql_mysql_p.h. It's a private api header, so if you want to use it you need to add something like
@QT += sql-private@
Be aware since it's a private API it can completely change anytime without any warning.
-
I think that did it. my model library linked. Thanks. Now on to other problems....
I changed my .pro file to say:
@QT += sql sql-private@
and seems to have just added the following '-I' options to the INCPATH in the Makefile:
@
-I"C:\Programs\Qt\5.3.1-base\qtbase\include\QtSql\5.3.1"
-I"C:\Programs\Qt\5.3.1-base\qtbase\include\QtSql\5.3.1\QtSql"
@But I see the private SQL headers are actually in:
@
-I"C:\Programs\Qt\5.3.1-base\qtbase\include\QtSql\5.3.1\QtSql\private"
@soooo, I just changed my header reference from:
@
#include <qsql_mysql.h>
@to:
@
if QT_VERSION >= 0x050300
include <private/qsql_mysql_p.h>
else
include <qsql_mysql.h>
endif
@
-
That's correct and expected, this has also the advantage of reminding you that you are doing something that can be dangerous ;)
-
Maybe, and that's a parking lot discussion.... If you look at the various (public) QtSQL classes n methods, one can easily use the lower-level classes. And, one needs to for embedded MySQL.
In any case, thanks again. And once I get my app working in this environment, I'll mark this thread as [solved].