Creating MySQL plugin for QtCreator, mingw73_64 without full Qt recompile.
-
Hello.
I've been reading many posts regarding this, but I have some troubles understanding the whole.
In Qt doc says to make a MySQL "custom install" but there is no "Libs & Include Files" option in their wizard (neither download option in the website). Maybe it's outdated.
Actually, there is the option for install Connectors.
Is the "Connectors" the correct MySQL install option?There are 3 connectors: C++ 64 bits, C 32 and C64 bits.
I choose C++... as Qt is for C++, but saw in another post chossing C 32bits connector and nobody says it was wrong.
What are the correct connector for Qt 64 bits?Seems that everything in MySQL is for MSVC compiler. Am I correct?
Do I need to convert it to mingw-like libraries (.a, if not wrong)? Are the "reimp" and "dlltool" mingw tools, as stated in this post, the way?
If it's true, why there is nothing about it in Qt Doc?In Qt Docs, also, there is some texts with the path where the libs and headers should be installed by default by MySQL wizard. This path is something like MySQL/server..../
For this reason, I tried to install server, but the libs and headers in there seems not the correct ones.
Actually, I tried installing server, C++ 8.0 connector and C 6.1 64 bits connector. But the commandconfigure -sql-mysql MYSQL_PREFIX=C:\mysql
reports allways that cannot find mysql header/libs:
ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.
I would like to compile just the driver.
When running this command:qmake -- MYSQL_INCDIR="c:\mysql\include" MYSQL_LIBDIR="c:\mysql\lib"
I get this error msg:
Project ERROR: You cannot configure sqldrivers separately within a top-level build.
What are the steps for compiling just the driver? I cannot find how to do it.Thank you.
-
Did you read https://forum.qt.io/topic/40672 ?
-
Thanks @Christian-Ehrlicher for your interest.
Yes I did. Not all the posts because its huge. In fact, there is a link to there in my original post. (where I talk about "reimp" and "dlltool")
But, you know...Just readed this post once again. It was opened in my browser while my research. I didn't give credit the last answer.
But... why not try? it's harmless.So:
Now I'm able to connect to FreeRadius MySQLi data base!
4 days.. 4 days reading, testing, frustrating...
And just copying a file did the trick?
Why it's not documented as it's so easy? -
Hi,
@Silderan said in Creating MySQL plugin for QtCreator, mingw73_64 without full Qt recompile.:
Why it's not documented as it's so easy?
Because, while it's working, it's not the correct solution. The dependencies your application uses should either be findable in the
PATH
environment variable or copied in the same folder as your application.This a Windows specific behaviour.
-
Hello @SGaist
(I'm really sorry if you didn't mean this. Sometimes it's hard to me to understand english)
I don't talk about where to put the .dll files.
The point is that two of the .dll needed are already compiled (both, release and debug, are in .../plugins/sqldrivers)
Only needed the libmysql.dll, and this is shiped along with MySQL install.
No need to bulid anything, just copy this .dll in C:\Qt\5.12.0\mingw73_64\binMaybe this is not the correct way as this .dll could not be the correct one and could fail in some scenarios.
Then... will be good if someone can help to compile it correctly. :P
-
If it's working it means that the .dll is compatible so you can just use it. What I meant is that copying .dlls around is the wrong thing to do.
For one reason: if you change your Qt version and the plugin of that version is built with another incompatible version of MySQL, you are going to have a hard time finding why it doesn't load just because you will likely have forgotten that you copied that .dll there.
-
Did you run
qmake
inside the MySQL plugin folder ? -
But, If I'm not wrong, this is because of...:
Also, found this: https://bugreports.qt.io/browse/QTBUG-62174
Sadly, this is far beyond my knowledge.
-
Since configure failed, did you check the reason of the failure ?
-
Found this in config.log:
loaded result for library config.qtbase_sqldrivers.libraries.mysql Trying source 0 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 1 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 2 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 3 (type mysqlConfig) of library mysql ... mysql_config not found. => source produced no result. Trying source 4 (type inline) of library mysql ... => source failed condition '!config.win32'. Trying source 5 (type inline) of library mysql ... + cd /d C:\Qt\5.12.0\Src\config.tests\mysql && C:\Qt\5.12.0\Src\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_USE += mysql" "QMAKE_LIBS_MYSQL = -LC:\\mysql/lib -llibmysql" "QMAKE_INCDIR_MYSQL = C:\\mysql/include" C:/Qt/5.12.0/Src/config.tests/mysql + cd /d C:\Qt\5.12.0\Src\config.tests\mysql && set MAKEFLAGS=& mingw32-make > g++ -c -fno-keep-inline-dllexport -g -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -I. -IC:\mysql\include -IC:\Qt\5.12.0\Src\qtbase\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:5:10: fatal error: mysql.h: No such file or directory > #include <mysql.h> > ^~~~~~~~~
But I wasn't able to figure out nor why cannot find the header (path is correct) neither how to change it (changing MYSQL_PREFIX=C:\mysql makes no diference. As if this is not the correct syntax)
Furthermore, by executing this three commands out of configure script shows no error:
-
MYSQL_PREFIX
is for Unix like OSes.You should also use forward slashes for your paths.
-
Well then... don't blame me. It's official doc info:
Furthermore I tried forward slashes, backward slashes, double backward...
No change at all :P (Remember what I said... using the same commands out of script, mysql libraries test compiles! Even mixing forward and backward slashes)Anyway, if
MYSQL_PREFIX
is not for Window. Why it is in official doc and witch one must we use? -
Then please re-read said documentation
You have a clear separation with:
How to Build the QMYSQL Plugin on Unix and macOS
and below you have:
How to Build the QMYSQL Plugin on Windows
So the technique for each is well separated.
And you are mixing the information for the configure script or for building using
qmake
. -
Once you said:
@SGaist said in Creating MySQL plugin for QtCreator, mingw73_64 without full Qt recompile.:
Since configure failed, did you check the reason of the failure ?
I figure out that I must run a success configure at first. Sorry for the confusion. My lasts posts were about configure tool, not building the plugins.
I'm not able to figure out the reason of the failure. Seems like test code is not able to get the header files, as if the headers don't exists or the include path is wrong. But my "out of the box" tests works.Anyway, I even tried
MYSQL_INCDIR
andMYSQL_LIBDIR
instead of *_PREFIX in configure step. Same result:Sorry again for not been clear enough.
-
One thing you can try is to use the "-I" and "-L" options of the configure script passing there the paths to your MySQL include and library folder.