Reputation: 2442
I have a application running on linux which I am trying to import on windows. I have set up all the libraries and also made changes to the .pro file. Now when I try to build the project I get this error:
error: LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
I am not sure what is causing this issue.I am using the 32-bit Qt creator. I know there are a couple of links which talk about changing the project properties but all those are related to changing them in Visual Studio. I am using Qt creator and running the project through the Qt UI. So I am not sure what changes have to be done for the project properties through Qt if this has to be resolved.
Upvotes: 7
Views: 15805
Reputation: 1
I had the same problem, i installed Qt 6.3.1 MSVC2019 but i got multiple linking error related to the architecture "LNK4272: library machine type 'x64' conflicts with target machine type 'x86'". i solved the problem by changing the compiler of the kit goto : edit -> preferences -> kits -> goto the MSVC2019 kit -> Compilers (C and C++) in my case they was "Microsoft Visual C++ Compiler 16.11.32630.194 (amd64_x86)" change it to amd64 (or your correct architecture)
Upvotes: 0
Reputation: 497
I had the same problem in Qt Creator when I was trying to build for a x64 machine using MSVC 2017. Somehow the linker would always be configured with a x86 target machine and fail.
I noticed that link.exe from a /x86/ directory was being called. Somewhere the path was "stuck". After searching for a while I found several incorrect paths in /MY PROJECTS BUILD DIRECTORY/CMakeCache.txt file. The header of this file indicated that it was generated by CMake: C:/Qt/Tools/CMake_64/bin/cmake.exe.
After replacing all the relevant occurences of 'x86' with 'x64' in that file, and rebuilding the project, the problem disappeared.
Upvotes: 0
Reputation: 101
I see this post was a while ago but I just ran across the same issue and this may be the solution for someone else that runs into this again. I have a different setup but I got the same error.
My application is running on Windows with Visual Studio 2019 and I needed mine to work properly in both x64 and x86 configurations. I ran into this error when I tried running my project in x86. Here was my solution.
Project -> <ProjectName> Properties
Configuration Properties -> Qt Project Settings
General -> Qt Installation
You can check this by checking your Qt Options in the Qt VS Tools Extension for VS. If you don't have it make sure you add it. Mine says "Qt5.13.2" which for me is pointing to the x64 build of Qt but it needs to be pointing to the x86 build.
Extensions -> Qt VS Tools -> Qt Options
Press the Add button to "Add New Qt Version"
Build Host: Windows
Version name: <give it a name> (I did "Qt5.13.2_86")
Path: <Path to correct build> (mine was "C:\Qt\Qt5.13.2\5.13.2\msvc2017")
compiler: msvc (automatically sets to this when selecting Windows for the Build Host)
Press OK
This was my solution for a different problem but the same error.
Upvotes: 0
Reputation: 147
It is obvious that you are compiling for 32 bits target but some of your libraries are 64 bits, which much likely you already know.
Make sure that Qt Creator is using the correct compiler (VC++, MinGW) and machine model (32, 64 bits) for your particular project.
Open your project
File -> Open File or Project... -> ... -> yourproject.pro
Check that Qt Creator auto-detected a compiler that meet the machine model of your libraries.
Tools -> Options -> Build & Run -> Kits
Select (define) the desired Build Kit and other settings for your project.
Select "Projects" from the left panel.
In the upper pane is shown the associated Kits for your project.
You can add more Kits with the "Add Kit v" button.
Hovering the mouse over the associated Kits, a little arrow is shown.
Clicking on it provides operations to apply to the Kit.
You can change or remove the Kit from your project following this little arrow.
Generate a new Makefile based on the new information.
Build -> Run qmake
Rebuild from scratch.
Build -> Rebuild All
Upvotes: 3
Reputation: 1764
I had the same problem but my scenario was a little different, I was targeting x64 architecture, and when I changed it to x86 I got this error, it took me some time to figure out that I had to re-build the project to match CPU architectures.
Upvotes: 6