Module machine type 'x64' conflicts with target machine type 'x86'
-
wrote on 3 Jun 2023, 11:23 last edited by Daniella 6 Mar 2023, 15:40
I'm trying to compile a
c++
Qt dll "Qt Class Library" on Visual Studio 22, I'm testing with a clean project, it does compile correctly on x64 but when I try the x86 version I'm getting this error:Severity Code Description Project File Line Suppression State Error LNK1112 module machine type 'x64' conflicts with target machine type 'x86' C:\Qt\Static\Debug\lib\objects-Debug\QWindowsIntegrationPlugin_resources_1\.rcc\qrc_openglblacklists.cpp.obj 1
I'm compiling the dll with the Qt source compiled as
static
using the "x64 Native Tools Command Prompt for VS 2022" and this command:configure.bat -static -debug -platform win32-msvc -opensource -confirm-license -skip qtwebengine -prefix "C:\Qt\Static\Debug"
I'm not sure which of these to use, then I compiled the source again.
When i compile the source using:
x64_x86 Native Tools Command Prompt for VS 2022It compile the x86 version of the dll, but the x64 version throw the machine type error.
x86_x64 Native Tools Command Prompt for VS 2022
It compile the x64 version of the dll, but the x86 version throw the machine type error.
I'm confused, is this correct? I really need to have two different builds of the source? one compiled with the
x64 Native Tools
and another with thex86 Native Tools
? Isn't possible to have it built only once and work with both versions?Is
-platform win32-msvc
the correct option when building the Qt source? -
@Chris-Kawa are you sure
-static
works with-debug-and-release
? i remember to try it once and it didn't work (maybe i did something wrong)@Daniella It should, but I haven't checked. If it doesn't you can build them separately, once for debug and once for release, but in any case you should have a Debug build for debugging and Release build for, well, releasing :)
-
I'm trying to compile a
c++
Qt dll "Qt Class Library" on Visual Studio 22, I'm testing with a clean project, it does compile correctly on x64 but when I try the x86 version I'm getting this error:Severity Code Description Project File Line Suppression State Error LNK1112 module machine type 'x64' conflicts with target machine type 'x86' C:\Qt\Static\Debug\lib\objects-Debug\QWindowsIntegrationPlugin_resources_1\.rcc\qrc_openglblacklists.cpp.obj 1
I'm compiling the dll with the Qt source compiled as
static
using the "x64 Native Tools Command Prompt for VS 2022" and this command:configure.bat -static -debug -platform win32-msvc -opensource -confirm-license -skip qtwebengine -prefix "C:\Qt\Static\Debug"
I'm not sure which of these to use, then I compiled the source again.
When i compile the source using:
x64_x86 Native Tools Command Prompt for VS 2022It compile the x86 version of the dll, but the x64 version throw the machine type error.
x86_x64 Native Tools Command Prompt for VS 2022
It compile the x64 version of the dll, but the x86 version throw the machine type error.
I'm confused, is this correct? I really need to have two different builds of the source? one compiled with the
x64 Native Tools
and another with thex86 Native Tools
? Isn't possible to have it built only once and work with both versions?Is
-platform win32-msvc
the correct option when building the Qt source?Lifetime Qt Championwrote on 3 Jun 2023, 15:42 last edited by Chris Kawa 6 Mar 2023, 15:54@Daniella said:
I'm confused, is this correct? I really need to have two different builds of the source?
Yes, 32bit and 64bit builds require different compilers and toolchains.
x64 Native Tools Command Prompt for VS 2022
opens a command line that sets up the environment for producing 64bit binaries.
x86 Native Tools Command Prompt for VS 2022
opens a command line that sets up the environment for producing 32bit binaries.Also, when you want to compile to x64 and x86 -platform win32-msvc is the correct option when building the Qt source?
Yes. The name is confusing but that's just 30 years of legacy naming shenanigans for you :) These days win32 pretty much just means Windows API. It' for all architectures - x86, AMD64, ARM and whatnot.
Will it work for x64 and x86?
Yes, it will work for both 32 and 64 bit builds. The choice between 32 and 64 bit build is done through the environment setup mentioned above.
Isn't possible to have it built only once and work with both versions?
No. These are different architectures. The binaries produced for 32bit and 64bit are different and incompatible. You can't mix 32 and 64 bit dlls and exes.
If you want to have one set of binaries you can just produce 32bit version if that's ok for you. 64bit Windows can run both 32 and 64bit apps. But if you're targeting modern Windows check if you really need 32bit support at all. Most consumer PCs have a 64bit OS these days.The x64_x86 and x86_x64 are cross-compilers, meaning that a 64 bit compiler will produce 32 bit binary or the other way around. There's usually no need to use it. You might need it if you're on a 32 bit system and need to produce 64 bit binaries or if your compilation is so big that you require 64 bit compiler to produce the 32 bit version e.g. due to memory limit issue. If you're not in those cases just use the regular x64 or x86 versions, not cross-compilers.
Also - are you sure you only want the Debug version? At some point you'll finish your app and want to distribute it. You shouldn't be distributing Debug builds. They are big and slow. Consider building both debug and release versions by passing
-debug-and-release
option to configure. -
@Daniella said:
I'm confused, is this correct? I really need to have two different builds of the source?
Yes, 32bit and 64bit builds require different compilers and toolchains.
x64 Native Tools Command Prompt for VS 2022
opens a command line that sets up the environment for producing 64bit binaries.
x86 Native Tools Command Prompt for VS 2022
opens a command line that sets up the environment for producing 32bit binaries.Also, when you want to compile to x64 and x86 -platform win32-msvc is the correct option when building the Qt source?
Yes. The name is confusing but that's just 30 years of legacy naming shenanigans for you :) These days win32 pretty much just means Windows API. It' for all architectures - x86, AMD64, ARM and whatnot.
Will it work for x64 and x86?
Yes, it will work for both 32 and 64 bit builds. The choice between 32 and 64 bit build is done through the environment setup mentioned above.
Isn't possible to have it built only once and work with both versions?
No. These are different architectures. The binaries produced for 32bit and 64bit are different and incompatible. You can't mix 32 and 64 bit dlls and exes.
If you want to have one set of binaries you can just produce 32bit version if that's ok for you. 64bit Windows can run both 32 and 64bit apps. But if you're targeting modern Windows check if you really need 32bit support at all. Most consumer PCs have a 64bit OS these days.The x64_x86 and x86_x64 are cross-compilers, meaning that a 64 bit compiler will produce 32 bit binary or the other way around. There's usually no need to use it. You might need it if you're on a 32 bit system and need to produce 64 bit binaries or if your compilation is so big that you require 64 bit compiler to produce the 32 bit version e.g. due to memory limit issue. If you're not in those cases just use the regular x64 or x86 versions, not cross-compilers.
Also - are you sure you only want the Debug version? At some point you'll finish your app and want to distribute it. You shouldn't be distributing Debug builds. They are big and slow. Consider building both debug and release versions by passing
-debug-and-release
option to configure.wrote on 3 Jun 2023, 15:55 last edited by Daniella 6 Mar 2023, 15:56@Chris-Kawa are you sure
-static
works with-debug-and-release
? i remember to try it once and it didn't work (maybe i did something wrong) -
@Chris-Kawa are you sure
-static
works with-debug-and-release
? i remember to try it once and it didn't work (maybe i did something wrong)@Daniella It should, but I haven't checked. If it doesn't you can build them separately, once for debug and once for release, but in any case you should have a Debug build for debugging and Release build for, well, releasing :)
-
-
@Daniella It should, but I haven't checked. If it doesn't you can build them separately, once for debug and once for release, but in any case you should have a Debug build for debugging and Release build for, well, releasing :)
wrote on 3 Jun 2023, 18:00 last edited by Daniella 6 Mar 2023, 18:02@Chris-Kawa I have compiled the source as
configure.bat -static -debug-and-release -platform win32-msvc -opensource -confirm-license -skip qtwebengine -prefix "C:\Qt\Static\x64_DebugAndRelease"
and thencmake --install .
Its working on release but not on debug, the folder is only 1.4gb i think it didn't installed the debug things, i'm also not finding the .pdbs in the
x64_DebugAndRelease
folder but i can see them into thesource
folder, do you know if i need any additional command when installing it? -
@Chris-Kawa I have compiled the source as
configure.bat -static -debug-and-release -platform win32-msvc -opensource -confirm-license -skip qtwebengine -prefix "C:\Qt\Static\x64_DebugAndRelease"
and thencmake --install .
Its working on release but not on debug, the folder is only 1.4gb i think it didn't installed the debug things, i'm also not finding the .pdbs in the
x64_DebugAndRelease
folder but i can see them into thesource
folder, do you know if i need any additional command when installing it?@Daniella
cmake --install .
will only install the release part of the build. Runcmake --install . --config Debug
after that to also install the debug part.
1/6