LNK1112: module machine type 'x64' conflicts with target machine type 'X86': Qt creator
Asked Answered
D

5

7

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.

Darius answered 6/1, 2015 at 21:30 Comment(3)
Somwwhere, the Micorosft compiler and linker command-line has to be invoked. See what the command line is for the MS linker.Builder
@Builder Yeah somewhere Qt is using the VS10 compiler for building the project. I am not sure where the changes have to be done.Darius
Never used Qt creator, but the fix is to get to the linker command line and fix the "MACHINE" option to use X86. Sorry I can't help any further.Builder
D
6

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.

Digitigrade answered 18/2, 2015 at 12:35 Comment(0)
N
3

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.

  1. Open your project

    File -> Open File or Project... -> ... -> yourproject.pro
    
  2. Check that Qt Creator auto-detected a compiler that meet the machine model of your libraries.

    Tools -> Options -> Build & Run -> Kits
    
  3. 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.
    
  4. Generate a new Makefile based on the new information.

    Build -> Run qmake
    
  5. Rebuild from scratch.

    Build -> Rebuild All
    
Nogging answered 6/11, 2015 at 2:49 Comment(0)
P
0

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.

  1. Go to your project's Properties page
Project -> <ProjectName> Properties
  1. Check your Qt Project Settings
Configuration Properties -> Qt Project Settings
  1. Make sure you are pointing to the correct Qt Installation under
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.

  1. To change this you need to create a Qt Version that points to the x86 build and change the Qt Installation in Qt Project Settings to point to that one.
Extensions -> Qt VS Tools -> Qt Options
  1. Under Qt Versions tab check the Qt Version that your Property Sheet was pointing to. If it is not correct for your configuration here is where you can create another one.

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

  1. Now go back to your Qt Installation under Qt Project Settings in your Configuration Properties in your Project's Property sheet and make it point to the correct Qt Version (Mine was from "5.13.2" -> "5.13.2_86").

This was my solution for a different problem but the same error.

Pearlstein answered 2/12, 2020 at 13:40 Comment(0)
M
0

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.

Marietta answered 25/12, 2021 at 17:58 Comment(0)
T
0

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)

Testator answered 6/9, 2022 at 15:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.