Qt windows libmysql.dll - mysql

I have installed MySQL 5.1.49 and the binary QT 4.6.2 for Visual Studio 2008. I configured Qt as follow:
C:\Qt>configure -static -no-webkit -plugin-sql-sqlite -plugin-sql-mysql -I C:\mysql\include -L C:\mysql\lib\optC:\Qt\src\plugins\sqldriver
Everything went fine, no errors. When I run nmake on my application everything runs fine, no errors as well. However when I execute my application under the debug folder I get a popup saying "Driver not loaded" (I have QT += sql under my project.pro)
If I goto C:\Qt\plugins\sqldrivers I dont see any libmysql, or any *mysql.dll only qsqlmysql.obj and qsqlmysqld.obj (there are files such as: qsqlite4.dll, qsqlpsql4.dll etc.)
I did try to build it manually by doing:
cd %QTDIR%\src\plugins\sqldrivers\mysql
C:\Qt\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\mysql\include" "LIBS+=C:\mysql\lib\opt\libmysql.lib" mysql.pro
nmake
Everything compiles fine, no errors. However, I still don't find any libmysql.dll generated. Only file found is under C:\mysql\bin\libmySQL.dll
I have all the includes for MySQL under C:\mysql\include and the libraries under C:\mysql\lib\opt
Any ideas what could be the problem? Thanks

Using -static prevents you from using plugins at runtime. You will need to change
-plugin-sql-mysql
to
-qt-sql-mysql
and have it compiled in.
B1.

Have you tried using qt source instead of the binary one? I had a similar issue, however I was getting compile errors.

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.

Cross-compile Qt5 (Mingw) with MySQL driver issue

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.
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.
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

Binary file refuses to run due to a missing shared library

I tried building recutils version 1.7 downloaded from the home page, using the standard configure, make, sudo make install sequence, but when trying to run the resulting binaries. like recinf, I get the error:
recinf: error while loading shared libraries: librec.so.1: cannot open shared object file: No such file or directory
Does this mean I made a mistake during the build or is the package itself in error?
As Etan Reisner said the problem was that the shared object libraries were installed but not loaded into the cache, hence the need to run ldconfig. After running
sudo ldconfig
the binaries ran properly. If I had looked in /usr/local/lib, I would have seen the libs there.

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.

Mysql Plug-in for Qt

I've installed recent Qt (4.5.3) sdk windows version. I'm want to use mysql in my app. Since Qt Mysql plugin in not available, so I compiled it from the included source. I copied compiled files D:\\Qt\2009.01\qt\plugins\sqldrivers.
Now when I run my application it still error "QMYSQL driver not loaded".
I suggest you take the whole Qt4 source code and compile it specifically for your own needs.
Something like this should do the job just fine:
Download the Qt source code from qt.nokia.com
Extract it somehwere and open a command prompt.
"cd" into the source directory and run "configure":
Just an example:
/Devel/qt/configure
-release
-fast
-opensource
-nomake "demos examples"
-silent
-qt-sql-mysql
You might have to additionally provide -I C:\path\to\mysql\includes and -L C:\path\to\mysql\libs.
After that, do "make install".
Hope that helps.
There may be several reasons leading to the driver not being loaded, I experienced several of them in my Qt experience.
Qt provides good documentation on this point, I suggest you have a look at the Troubleshooting subsection of Qt Assistant's SQL Database drivers section, it should help you diagnose your problem. It worked for me.
Hope that helps.
After compiling the plugin, you need to add the MySQL bin path to your PATH environment variable.