Cannot build MySQL plugin
-
Hello,
I am a hobbyist programmer and a totally newcomer to Qt, but I have moderate experience in C ++ and other SDKs
Since I want to focus on database application development for my personal needs, I tried to connect to a MySQL database. Soon I realized that I have to build, by myself, the MySQL plugin
I followed various instructions reading relative threads from this forum and watched YouTube videos. I also read the official help files (https://doc.qt.io/qt-5/sql-driver.html) of this topic, but I didn't manage to build the plugin.
I have installed the Qt 5.14.2 and the MySQL Connector to the following paths in my hard drive:
"C:\Qt" and
"C:\Program Files\MySQL\MySQL Connector C 6.1"
I think there are two methods to build the plugin. The first method is to open the corresponding project (in my case the MySQL) from the following path:
"C:\Qt\5.14.2\Src\qtbase\src\plugins\sqldrivers\mysql"
I modified the project in order to include the needed header files and include the needed libraries as follows:
but the Qt creator says that "library mysql is not defined"
The second method is the command line prompt using the qmake. The following image shows the same error:
I don't know what I am doing wrong and I am stuck. Any help will be appreciated -
@george said in Cannot build MySQL plugin:
Before I start, I am wondering if I have to modify the project file
You shouldn't.
I had added the following lines
Don't do that, you provide the paths on the command line, as per the documentation. Don't forget to quote the paths, as they contain spaces.
-
You did not set up your environment correct. When you use MSVC you have to open the correct visual studio command prompt. When using MinGW then it's not nmake but mingw32-make (as written in the documentation)
-
Hi,
If it's the one matching the Qt version used in your Kit then yes.
-
You should check the test logs generated to see what exactly failed when the detection ran.
-
In the folder where you call qmake.
-
In the folder where you call qmake.
I call the qmake from the folder:
C:\Qt\5.14.2\Src\qtbase\src\plugins\sqldrivers\mysql
In the following image there is a list of all files. There is no log files there (all subfolders are empty)
http://www.mediafire.com/view/vgec6rp2ldmf9lh/qt%25235.jpg/file
-
Hi,
Open the.pro
file for the plugin and change the line which reads:QMAKE_USE += mysql
to:
# QMAKE_USE += mysql
Then rerun
qmake
and build withmake
/nmake
. Then you can see what the compiler complained about exactly. Do let us know, I had that problem compilingpsql
because I mixed the arch by accident. -
Hi kshegunov,
Although I don't know what the QMAKE_USE += mysql instruction does, I understand that the '#' symbol is for remarks
I followed your instruction.
From the command prompt, I am getting no messages, so I opened the project from the creator and there are no errors.
The compiler output window among other displays something about "win32-msvc", but I've the 64bit version installed:20:06:46: Running steps for project mysql... 20:06:46: Starting: "C:\Qt\5.14.2\msvc2017_64\bin\qmake.exe" C:\Qt\5.14.2\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
In the following image you can see the full compiler output
http://www.mediafire.com/view/vfi179q0efuqh5t/qt%25236.jpg/file
But if everything is OK, where is the plugin? I searched for a ".dll" file in the subfolders but all they are empty -
You did not follow the documentation - you have to run qmake in the sqldrivers subdir...
-
@george said in Cannot build MySQL plugin:
From the command prompt, I am getting no messages, so I opened the project from the creator and there are no errors.
You didn't invoke the generated makefile as far as I could see from your screenshot. So I wouldn't expect you to see any messages. ;) After you run the
qmake
, you do need to callnmake
to start things rolling.@Christian-Ehrlicher said in Cannot build MySQL plugin:
You did not follow the documentation - you have to run qmake in the sqldrivers subdir...
True, but don't lose patience on us. He just tried to follow what I asked, have some faith. ;)
-
First of all, I would like to thank you for spending your valuable time, reading my posts and try to guide me.
It is true that I went a step forward. First I ran the vcvarsall.bat (I did not execute this batch file before). I suppose that sets some environment variables, right?
From the command prompt and in the following directory: "C:/Qt/15.4.2/Src/qtbase/src/sqldrivers" I build the plugin as follows:qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
Here is the output:
http://www.mediafire.com/view/swazfssbaa0dg2u/qt%25237.jpg/file
But what is the next step?
If I enter:nmake sub-mysql
as manual says, I am getting the following errors:
Microsoft (R) Program Maintenance Utility Version 14.16.27035.0 Copyright (C) Microsoft Corporation. All rights reserved. cd mysql\ && ( if not exist Makefile C:\Qt\5.14.2\msvc2017_64\bin\qmake.exe -o Makefile C:\Qt\5.14.2\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro ) && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe" -f Makefile Microsoft (R) Program Maintenance Utility Version 14.16.27035.0 Copyright (C) Microsoft Corporation. All rights reserved. "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe" -f Makefile.Release all Microsoft (R) Program Maintenance Utility Version 14.16.27035.0 Copyright (C) Microsoft Corporation. All rights reserved. link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /OPT:REF /INCREMENTAL:NO /DLL /SUBSYSTEM:WINDOWS /VERSION:5.14 /OUT:..\plugins\sqldrivers\qsqlmysql.dll @C:\Users\George\AppData\Local\Temp\nmEA57.tmp LINK : fatal error LNK1181: cannot open input file 'lmysql.obj' NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.EXE"' : return code '0x49d' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.
-
@george said in Cannot build MySQL plugin:
LINK : fatal error LNK1181: cannot open input file 'lmysql.obj'
Do you by any chance use a statically built Qt? This linker error is rather odd.
-
@kshegunov said in Cannot build MySQL plugin:
Do you by any chance use a statically built Qt?
Hmm... How can I check this?
I searched my entire hard drive for the file "lmysql.obj", but I found nothing -
Please make sure that there are no leftovers in the sqldrivers subdir (best is to remove this subdir and unpack it again) and try again.
-
@george said in Cannot build MySQL plugin:
I searched my entire hard drive for the file "lmysql.obj", but I found nothing
Hence I was suspicious. How did you obtain the sources, did you clone them from git or unpacked them from an archive, or maybe installed them through the maintenance tool? Christian's advice is a good one at this point, you want to make sure there are no leftovers because that can break the build.
-
I'll uninstall the Qt entirely and I'll delete the Qt folder.
Then, I'll install from scratch the SDK using the online installer (only the MSVC 64 bit compiler)
Then I'll let you know since the installation will take some time. -
Sounds like a plan.
@george said in Cannot build MySQL plugin:
Then, I'll install from scratch the SDK using the online installer (only the MSVC 64 bit compiler)
One one note here, make sure that the SDK architecture (and compiler) you select matches the one of your command prompt that you're going to use. I had experienced this cryptic error when I tried to compile the PSQL driver with a 64 bit msvc, while my Qt distro was for 32 bit msvc. I know it sounds silly but it's an easy error to make, and not very obvious if you actually make it.