Qt - Where is the mysql driver in Qt 5.12.6? - mysql

I started to notice that after version 5.12.3 none more came with the plugin driver, I can't find any information about removing the plugin, I also tried to compile it through this tutorial: https://www.youtube.com/watch?v=r1TbNjJSlX8, but to my surprise I didn't have the source for the sql module in the source files

Related

QMSQL : Cannot mix incompatible Qt library (version 0x50b03) with this library (version 0x50c05)

I'm trying to use a MySQL database in a QT application. For this I needed to build the MySQL manually and nothing went as planned at all.
Using:
Qt 5.12.5
g++ 8.3.0
Make 4.2.1
MySQL 15.1
Debian 10.1
I first tried to follow this guide: https://doc.qt.io/qt-5/sql-driver.html but qmake wouldn't detect MySQL headers.
After searching the internet I found out somebody managed to work things out by building directly the driver.
I went in ~/Qt/5.12.5/Src/qtbase/src/plugins/sqldrivers/mysql and ran :
qmake qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib/x86_64-linux-gnu/ -lmysqlclient_r"
It didn't work :
Project ERROR: Library 'mysql' is not defined.
After some googling, I changed the mysql.pro file to this one:
TARGET = qsqlmysql
HEADERS += $$PWD/qsql_mysql_p.h
SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
OTHER_FILES += mysql.json
PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
include(../qsqldriverbase.pri)
It worked, for now. Next step, running make ! Guess what? Didn't work either.
/usr/include/c++/8/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
ran qmake again without "INCLUDEPATH [...]", now I was missing mysql.h. I added manually the path to it to the Makefile. It worked.
I tried running my QT app again, still no MySQL driver.
Turned out the newly built driver was not copied in the right directory with the other ones. So I copied in Qt/5.12.5/gcc_64/plugins/sqldrivers.
Now it seems my plugin is indeed recognized by Qt but it just crashes with this error :
Cannot mix incompatible Qt library (version 0x50b03) with this library (version 0x50c05)
I don't know what to do next, can't find anything useful for this case on the internet...
Help, please?
Turned out I had another version Qt installed on my system. I don't where it came from but this issue is now solved.

MySQL Driver not loaded on Qt

Trying to connect to MySQL using
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
gives me the
Driver not loaded error
Reading the other questions and answers did not help me because they have qt4 instead of 5 that I am using, and they had to build the drivers themselves. I do have the drivers though
And I also did load the path in the pro file here
So why is this happening? Should I try and compile the drivers myself as suggested in some other questions?
EDIT
I also did make sure to use MySQL 32bit.
In Debug Mode on development machine the Qt-Framework Installation is enough.
In Release Mode you will have to provide the required driver in the sqldrivers-folder located in your working directory: $(wcd)/sqldrivers/*
Edit:
Check output of: QSqlDatabase::drivers () Eventually rebuild sql drivers for your system using $QTDIR/src/plugins/sqldrivers/mysql/mysql.pro.
Also try adding mysql-client-library to your working directory directly or setting up a library path to look for. It is not enough to add INCLUDEPATH / LIB in pro file, since this is for compile/link time only. During runtime the executable looks in the known places (typical windows: $WINDIR/system32/;$PATH;...)

Compiling sqlite-winrt for using SQL in WinRT/WP app with SQLite

I'm trying to use the sqlite-winrt library at https://sqlwinrt.codeplex.com (cf. http://blogs.windows.com/windows_phone/b/wpdev/archive/2013/05/30/sqlite-winrt-wrapper-for-windows-phone.aspx) because I need to access an SQLite database via SQL commands in a WinRT 8.1 and a WP8 app and this library seems the only available option.
Anyway, there is no binary release and if I try compiling the source I get several link errors for unresolved externals against the SQLite DLL. I posted an issue at codeplex but got no reply yet, so I was wondering if anyone had already managed to successfully compile this lib and how (or if you know of any viable alternative for RT8.1 and WP8). Here is what I did:
downloaded the latest source from the site.
downloaded and installed 2 VSIX from http://www.sqlite.org/download.html: sqlite-winrt81-3080002.vsix for RT 8.1 and sqlite-wp80-winrt-3080100.vsix for WP.
executed the powershell scripts in each subfolder of the source code solution, which are required to update the projects with newer releases of the SQLite for WinRT extension. The current versions of the scripts refer to SQLite for WinRT 8.1 (prerelease) which is the same I downloaded above.
opened the VS2013 solution and removed the RT project (I just need RT8.1 and WP, this was for WinRT 8.0).
5) built the solution, which failed with link errors.
If I see the RT8.1 project properties, I can confirm the reference to SQLite is under C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\SQLite.WinRT81\3.8.0.2.
Did anyone manage to use this lib? Thanks!
I also once had that problem. I fix it by editing the project file manually. At that time, the powershell script updating the wrong path. That's why I always failed when compiling my project. After I edit the project file using external text editor (I use sublime text), the projects are linked correctly.
You can try DatabasesCx. It is another SQLite Wrapper using Windows Runtime Component technology. It is freeware distributed as precompiled binary. You can find the details at http://www.almanacsoft.com/databasescx

Installing QMYSQL driver

Basically when I try to connect to the mysql database i get this error:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3
I tried to install the drivers, extracting just qtbase from http://download.qt-project.org/official_releases/qt/5.0/5.0.2/single/qt-everywhere-opensource-src-5.0.2.zip and placing it in my Qt directory. I have also followed this guide by inbush: http://www.qtcentre.org/threads/45295-using-mysql-plugin doing this: http://puu.sh/3nyG9.png
inbush says to copy libmysql.dll from C:\mysql\bin to C:\Qt\bin but I didn't find libmysql.dll in bin, but I did find it in lib. So I took that and went to my Qt\bin, and noticed that it was just these files http://puu.sh/3nB5m.png so I thought to place it in Qt\lib instead. I tried re-running my project but it still gave me the same error. My .pro file does indeed have Qt += sql, and I did run qmake afterwards. What am I doing wrong?
Take a look at this post for Qt5, there's also a seperate set of instructions for Qt4 (although somewhat similar).
Qt - How to get|compile Mysql driver
Download a version of MySQL
Download Qt source
Build the MySQL plugin for Qt
Copy the DLL from the MySQL install folder to a Qt folder (see link above)
Copy the DLL you built for the Qt MySQL plugin to a Qt folder
And obviously, when you distribute you'll need to remember to package those DLLs together (always check dependency walker)

MySQL++ Application error at launch

I compiled MySQL++ with no issues. When I launched some of the executables (resetdb.exe and simple1.exe) they suggest to run to test if the installation has been successful, the first error I got was that libmysql.dll was missing.
Adding its path to the PATH environment variable did not fix the problem, even after launching a new command prompt; I had to copy the DLL in the directory where MySQL++ executables are.
Now the DLL is found, but I get this error:
simple1.exe - Application error
The application was unable to start correctly (0xc000007b).
Click OK to close the application.
even launching from the command line, I get no more information than these.
Thank you for any help!
MySQL 5.5 -
MySQL++ 3.0.9 -
Windows 7 64 bits -
MINGW32 -
GCC 4.4.0
0xC000007B is a Windows error that means the executable is corrupted. It could refer either to simple1.exe or to one of the DLLs it's linking against.
Some reasons this could happen:
You're mixing toolchains in an incompatible way. In your case, you may have built simple1.exe using pieces built by MinGW GCC and pieces built by Visual C++. MinGW should be compatible with any pure C DLL built by Visual C++, including the MySQL C API DLL. However, you may have other pieces interfering. MinGW isn't compatible with VC++ at the C++ level, but then, it shouldn't have linked at all if this were your problem.
You didn't follow the MySQL C API import library build steps in README-MinGW.txt. You either missed a step, or skipped it entirely and are trying to use the import library that shipped with MySQL.
In your previous gyrations, you ended up with a corrupt object file, which got linked in. Try saying make clean all at the top level of MySQL++ to force a complete rebuild.
You're mixing versions of MySQL or MySQL++. If you have more than one version of each on the system, make sure you're consistent in their use. That is, build the C API import library from the same DLL you run the programs against, use exrun.bat to run the examples to ensure you're using the just-built version of the MySQL++ DLL instead of another you have in your PATH, etc.
Additionally, I note that you're using an older version of MySQL++. If you were on Linux, I could understand that as some distributions still ship with 3.0.9. But since you have to build MySQL++ from source with MinGW, I don't see why you're not using 3.1.0. Did you get a binary build from somewhere?
As for your PATH problem, did you restart the MinGW shell after doing this? PATH updates don't affect running programs; they keep the value they saw when they started.