Solved Cannot build MySQL plugin
-
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.
-
@kshegunov said in Cannot build MySQL plugin:
make sure that the SDK architecture (and compiler) you select matches the one of your command prompt that you're going to use
I noticed that the installer, creates only those command prompts shortcuts in the windows start menu that they correspond to the compiler versions chosen during the installation.
I choose only one compiler to avoid such errors. When I will get better knowledge of how Qt works then, I'll proceed with other compilers too -
Now I have a fresh installation of Qt in my hard drive
Before I start, I am wondering if I have to modify the project filemysql.pro
in the following folder:
C:\Qt\5.14.2\Src\qtbase\src\plugins\sqldrivers\mysql
as I did in my first post. I had added the following lines:
INCLUEPATH += C:/Program Files/MySQL/MySQL Connector C 6.1/include QMAKE_LIBDIR += C:/Program Files/MySQL/MySQL Connector C 6.1/lib LIBS += -lmysql
-
@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.
-
Well, I managed to connect with my database, thanks to all the people they responded to my posts, and especially to you kshegunov
The most important reason that I've never used the QT, it is I never manage to connect with a remote database. Now I can use and learn this SDK which I believe it is the most comprehensive SDK around C++, targeting to database applications for my personal needs
For people like me who does not have good knowledge around Qt I will post the steps I followed:
-
Make a fresh install of Qt BUT only one compiler (if you do not know what are you doing!). I choosed the MSVC 2017 64bit. I installed the QT in C:\Qt
-
Install the MySQL Connector . I installed in C:\Program Files\MySQL\MySQL Connector 6.1
-
Click on the Windows start menu the shortcut for the command prompt of MSVC 2017 64-bit
-
Find in your hard drive the file vcvarsall.bat and execute it (you sould have Microsoft Visual Studio 2017 installed on your hard drive)
-
Go to the C:\Qt\5.14.2\Src\qtbase\src\plugins\sqldrivers and execute the following command (according to Qt manual)
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"
and then
nmake
and then
nmake install
You'll see a lot of output. If everything is OK you should see the following files:
qsqlmysql.dll and qsqlmysqld.dll
in the folder C:\Qt\5.14.2\msvc2017_64\plugins\sqldrivers (see the first image of this post) -