Solved Building QMYSQL Plugin with nmake for msvc2017: module machine type 'x86' conflicts with target machine type 'x64'
-
Ok calling nmake in the sqldrivers directory after configuration is still giving the "Qt5Sql.lib(Qt5Sql.dll) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'" error even though I am using the 64 bit compiler? (According to Microsoft docs the x64 Native Tools Command Prompt for VS 2017 does use the 64 bit compiler https://docs.microsoft.com/en-us/cpp/build/how-to-enable-a-64-bit-visual-cpp-toolset-on-the-command-line?view=msvc-160)
If the connector is 64 bit and Qt is x86_64 then I still don't understand why I can't build in the 64 bit compiler.
-
How exactly are you opening/configuring the command line ?
-
Thanks jsulm and SGaist for your help with this. Before I explain about the command line, I just want to quickly summarise progress so far.
I've tried reinstalling Qt and MySql to ensure that they both have the same architecture:
-
For Qt, based on Jsulm's comment above and the fact that Qt's installer doesn't ask which architechture to use, I am assuming I have installled Qt 5.14.2 x64.
-
For mySql, according to Qt's instructions, since I have x64 Qt installed, I need the x64 mySql C connector, and no other components of the MySql installation are relevant for building the qmysql plugin. Having now played around with the MySql installer, depending on which C connector I install, I get a different error at the nmake stage of building the plugin.
This is what I see when I run the MySql installer. It doesn't allow me to simultaneously install the 32 and 64 bit C connectors:
When I have the 32 bit C connector installed (as shown in the screenshot above), the following qmake command runs fine:
qmake -- MYSQL_INCDIR="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1.3\include" MYSQL_LIBDIR="C:\Program Files (x86)\MySQL\MySQL Connector C 6.1.3\lib"
However, when I then run nmake sub-mysql, nmake complains:
NMAKE : fatal error U1073: don't know how to make '"C:\Program Files\MySQL\MySQL Connector C 6.1.3\include\mysql.h"'
This makes sense because I have x64 bit qt installed, but qmake and nmake are being given the path to the 32 bit version of the C connector.
When I have the 64 bit C connector installed, I run the following qmake command:
qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Connector C 6.1.3\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Connector C 6.1.3\lib"
Now when I run nmake sub-mysql, I get the error reported at the beginning of this thread:
Qt5Sql.lib(Qt5Sql.dll) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
The point of the above explanation is that nmake gives me a different error depending on whether I have the 32 bit or 64 bit mySql C connector installed, which means that I can be fairly confident that I have the 64 bit version of both MySql C connector and Qt based on the error messages that I am seeing from nmake.
Visual Studio 2017 includes four different command prompts in which I can execute qmake and nmake:
- x86 Native Tools Command Prompt for VS 2017
- x64 Native Tools Command Prompt for VS 2017
- x64_x86 Cross Tools Command Prompt for VS 2017
- x86_x64 Cross Tools Command Prompt for VS 2017
When I run qmake and nmake using the above commands in each of these four prompts, the error messages are the same as above , with one exception: when I call qmake for the 32 bit mySql driver in the 64 bit command prompts, or vice versa, qmake does not recognise that mySql has been configured at all when it gives the list of database drivers available.
So in summary, whichever version of the MySql C connector I have installed, and whichever version of the command prompt I use, I always get the same errors.
Thanks to you both again for your help with this issue, it is much appreciated.
-
-
@obradley said in Building QMYSQL Plugin with nmake for msvc2017: module machine type 'x86' conflicts with target machine type 'x64':
Qt5Sql.lib(Qt5Sql.dll) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
AFAIR, this message means that Qt5Sql is 32bit which is rather strange since it's supposed to be 64 based on what you wrote. Are you sure the correct qmake is called ? Do you have any Qt variable in your environment variables ?
-
Hi,
I just wrote a quick console application in vs2017 for an x86 build that returns the value of the QSysInfo::currrentCpuArchitechture() and QSysInfo::buildCpuArchitechture() strings. They return x86_64 and i386 respectively. Since the current cpu architechture returns x86_64, this should mean that Qt is x86_64 am I correct?
In my system path variables I have C:\Qt\Qt5.14.2\5.14.2\msvc2017\bin, and in my user variables I have C:\Users\OBradley\AppData\Local\QtMsBuild as QtMsBuild. These are the only Qt related variables I can find.
Calling qmake -version returns
QMake version 3.1 Using Qt version 5.14.2 in C:/Qt/Qt5.14.2/5.14.2/msvc2017/lib
The msvc2017 folder, I believe, contains 32 bit libraries since there is also I folder called msvc2017_64 which surely contains the 64 bit versions. Should I be using qmake from here?
For context, I do want a 32 bit qsqlmysql.dll since I want to use it with a 32 bit vs2017 executable.
-
@obradley said in Building QMYSQL Plugin with nmake for msvc2017: module machine type 'x86' conflicts with target machine type 'x64':
For context, I do want a 32 bit qsqlmysql.dll since I want to use it with a 32 bit vs2017 executable.
Then use qmake from 32bit Qt
-
@jsulm said in Building QMYSQL Plugin with nmake for msvc2017: module machine type 'x86' conflicts with target machine type 'x64':
Then use qmake from 32bit Qt
I'm wondering if the version of qmake being called is 32 bit because it resides in the msvc2017 folder and not the msvc2017_64 folder. Do you know of a way to test the architecture of the qmake that is being called?
-
@jsulm said in Building QMYSQL Plugin with nmake for msvc2017: module machine type 'x86' conflicts with target machine type 'x64':
Then use qmake from 32bit Qt
Update:
Assuming that the qmake executable in the msvc2017 folder is the 32 bit qmake, I replaced the version of qmake sitting the MSVC2017 folder with the executable from the msvc2017_64 bit folder, which is most likely a 64 bit version of qmake. The current mySql C connector I have installed is the 64 bit version, so I then reran the qmake process in the two VS command prompts that configure for the 64 bit sql connector (x64 Native Tools Command Prompt for VS 2017 and x86_x64 Cross Tools Command Prompt for VS 2017). The result was the same error as before:Qt5Sql.lib(Qt5Sql.dll) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64' NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.EXE"' : return code '0x458' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.
To be certain I then redid the process in the x86 Native Tools Command Prompt for VS 2017 and the x64_x86 Cross Tools Command Prompt for VS 2017 and got the same result as before for those command prompts when trying to use a 64 bit C connector, i.e. qmake being unable to configure the sql driver:
Running configuration tests... Checking for DB2 (IBM)... no Checking for InterBase... no Checking for MySQL... no
-
@obradley said in Building QMYSQL Plugin with nmake for msvc2017: module machine type 'x86' conflicts with target machine type 'x64':
For context, I do want a 32 bit qsqlmysql.dll since I want to use it with a 32 bit vs2017 executable.
Then why
@obradley said in Building QMYSQL Plugin with nmake for msvc2017: module machine type 'x86' conflicts with target machine type 'x64':
The current mySql C connector I have installed is the 64 bit version,
?
You can't mix and match libraries from different architecture.
The fact that your Windows is 64 does not matter as it can run both 32 and 64bit code.
-
Hi,
I've just done another clean install of Qt. This time I only installed the 32 bit msvc2017 folder and the source folders so as to keep things simple. I also uninstalled the Qt for Visual Studio plug in, and ensured that I was building using the 32 bit my sql c connector and this time the same steps I performed in my original question worked (except having qmake point to the 32 bit MySql connector in program files (x86) and using x86 Native Tools Command Prompt for VS 2017). It is worth pointing out that at some point previously I had tried building the dll with this exact setup when I was exhausting all combinations, and that because my system path variable points to the qmake that sits in the 32 bit msvc2017 folder, I was always using 32 bit qmake, so at some point my 32 bit attempts should have worked yet they did not.
This leaves me with two possible candidates (I think) that possibly could have been causing the error, although I cannot spare time to investigate which one it was:
- Having multiple bit builds of Qt installed caused a conflict somewhere when building the 32 bit dll, and this was then resolved when I uninstalled the other builds and just had the 32 bit version.
- The Qt for VS2017 plugin was causing a conflict somewhere, which was then resolved when I uninstalled the plug in.
Thank you both for your patience and your help.