[VS2010] 编译64位静态库lib提示fatal error LNK1112: module machine type 'x64' conflicts等错误的解决方案
2018年01月17日 19:40:59
阅读数:147
环境
Win7 x64
Visual Studio 2010
程序写完,本想导出dll(x64)、lib (x64),在动态链接库dll下编译成功。
但是在编译静态库lib时,出错了
报错如下:
1>—— Build started: Project: EditAlgoTestFrameWork, Configuration: Release x64 ——
1>Build started 1/17/2018 11:32:37 AM.
1>InitializeBuildStatus:
1> Creating “x64\Release\EditAlgoTestFrameWork.unsuccessfulbuild” because “AlwaysCreate” was specified.
1>ClCompile:
1> All outputs are up-to-date.
1>ResourceCompile:
1> All outputs are up-to-date.
1>Lib:
1> All outputs are up-to-date.
1>LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
1>x64\Release\Test.obj : fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.20
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
原因
由于项目默认 /MACHINE属性值为X86,故在编译lib(x64)时,需要显式指定其值为X64
解决方案
项目右键属性(Properties) –> 配置属性(Configuration Properties) –> 库管理器(Librarian) –> 命令行(Command Line) –> 其他选项(additional Options) 指定/MACHINE值为X64:
/MACHINE:X64
保存并重新编译即可通过。