CppPilot

Linker diagnostic Visual Studio C++

LNK1112 module machine type conflicts with target machine type

An object file or a library was built for another processor architecture than the program being linked.

Applies toMSVC on Windows; code and debugger concepts apply to MSBuild and CMake
ExamplesFocused excerpts; required context is stated alongside each example

Visual Studio property-page paths describe MSBuild projects. For CMake, configure the corresponding target or preset. Menu names can vary by Visual Studio version; use the cited reference for your toolset.

Build output
fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86'

Causes & corrections

Find the case that matches your build. Each example shows what changes and why.

  1. A library was built for the other platform.

    Link the x64 build of the library in x64 configurations and the x86 one in Win32, with platform-specific paths in Linker > General > Additional Library Directories, such as lib\$(PlatformTarget).

    Problem

    App: x64Library folder: lib\x86

    Correction

    App: x64Library folder: lib\x64Inspect architecture with dumpbin /headers
    Note 1Select a library actually built for the target architecture.
  2. The target machine is set by hand.

    Set Linker > Advanced > Target Machine back to Not Set, or remove /MACHINE from the additional options.

    Problem

    Configuration: x64Additional Options: /MACHINE:X86

    Correction

    Linker > Advanced > Target MachineNot SetRemove conflicting /MACHINE from Additional Options
    Note 2Let the selected platform determine the machine type unless an override is required.
    VideoFilmed in Visual Studio: this case fixed by hand, then with CppPilot. English narration, with subtitles in English, French, German, Italian and Spanish.
    Transcript

    LNK1112, module machine type conflicts with target machine type: fixed by hand, then with CppPilot. Sensors is an x64 project, but the link fails with LNK1112: its x64 object files conflict with an x86 target machine.

    Open Project > Properties, Linker > Advanced: Target Machine was set to MachineX86 by hand. Set it back to Not Set: the linker then follows the platform of the project.

    Build again: the program is linked for x64, and the build succeeds. Now the same error, fixed by CppPilot.

    After the failed build, select the error in the Error List, and click Fix with CppPilot. Click Fix on the LNK1112 card.

    The AI finds the target machine forced to x86 in the project file, and sets it to x64, the platform of the project. CppPilot rebuilds the project to check the fix: the error is resolved.

    CppPilot explains and fixes C++ build errors in Visual Studio.

  3. Old object files remain in a shared folder.

    When Win32 and x64 share the intermediate directory, objects of one platform are linked into the other: include $(Platform) in Intermediate Directory and rebuild.

    Problem

    Win32 and x64 both write obj\main.obj

    Correction

    General > Intermediate Directory$(Platform)\$(Configuration)\$(ProjectName)Clean and rebuild the affected projects
    Note 3Separate intermediate files by architecture, configuration, and project.

Sources and scope

Official references

These links document the compiler, build system, or debugger behavior discussed here. Use the version selector on Microsoft Learn for your toolset. Example blocks are focused excerpts; required headers and build settings are stated alongside them.

In your workspace

Investigate LNK1112 with CppPilot

CppPilot gives the selected AI the diagnostic, relevant code, and project settings for the active configuration. Choose Fix to request a correction, then check the result with a rebuild.

Use your own Codex or Claude account, or optional CppPilot Cloud access. Setup instructions

Visual Studio Marketplace