Brady Dean
Brady Dean

Reputation: 3573

Clang++ Windows LNK1112 error

I build Clang/LLVM using VS12 Win64

clang version 3.7.0 (http://llvm.org/git/clang 9a5a6f0e149ba035168641ca6dc4e3b3e
5aa29b5) (http://llvm.org/git/llvm 1de72bda4e6114393ddc8bad2c13d8abee3d374a)
Target: x86_64-pc-windows-msvc
Thread model: posix

When compiling this:

#include <iostream>

using namespace std;

int main() {
    cout << "Hello World!" << endl;
}

I receive this error:

libcmt.lib(typinfo.obj) : fatal error LNK1112: module machine type 'X86' conflic
ts with target machine type 'x64'
clang++.exe: error: linker command failed with exit code 1112 (use -v to see inv
ocation)

LNK1112 seems to be about using wrong machine target types but I don't know how this applies to Clang

Upvotes: 4

Views: 496

Answers (1)

Angle.Bracket
Angle.Bracket

Reputation: 1520

Just stumbled over this question and thought this might help:

As Clang (at least as of version 10.0.0) under Windows by default uses the linker provided by MS Visual Studio to produce the executable, the path variable to your link.exe most probably points to the 32-bit version and thus the linker tries to link the 32-bit version of the library to your 64-bit object file in order to produce a 64-bit executable file, resulting in the LNK1112 linker error.

There are two ways to solve this issue: either use a 32-bit version of Clang or a 64-bit version of link.exe.

Upvotes: 1

Related Questions