Clang ++ Windows LNK1112错误

时间:2015-05-24 02:06:36

标签: linker-errors clang++

我使用VS12 Win64构建Clang / LLVM

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

编译时:

#include <iostream>

using namespace std;

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

我收到此错误:

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似乎是关于使用错误的机器目标类型但我不知道这如何适用于Clang

1 个答案:

答案 0 :(得分:1)

偶然发现了这个问题,并认为这可能会有所帮助:

由于默认情况下Windows下的Clang(至少从10.0.0版开始)使用MS Visual Studio提供的链接器来生成可执行文件,因此link.exe的path变量很可能指向32位版本,并且因此,链接器尝试将库的32位版本链接到您的64位目标文件,以便生成64位可执行文件,从而导致LNK1112链接器错误。

有两种方法可以解决此问题:使用32位版本的Clang或64位版本的link.exe。