【发布时间】:2017-05-10 13:34:14
【问题描述】:
我是使用 cmake/visual studio 构建、编译项目的新手,所以请放轻松;)。
我正在尝试配置VSAL lib。我使用 CMake GUI 进行配置和生成(Visual Studio 2015 编译器)。
当我在 Visual Studio 中构建 ALL_BUILD 时,出现以下错误:
1>------ Build started: Project: vsal, Configuration: Release x64 ------
1>libboost_program_options-vc140-mt-1_64.lib(value_semantic.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
2>------ Build started: Project: vsal_player, Configuration: Release x64 ------
2>LINK : fatal error LNK1181: cannot open input file '..\lib\Release\vsal.lib'
========== Build: 0 succeeded, 2 failed, 2 up-to-date, 0 skipped ==========
困扰我的一件事,为什么 CMake 使用 x86_amd64 而不是 amd64 编译器。
Check for working CXX compiler: G:/Programske datoteke (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working CXX compiler: G:/Programske datoteke (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
版本:
- Visual Studio 专业版 2015
- CMake 3.8.0
- 提升 1.64.0
- vsal 1.0
感谢您的帮助!
【问题讨论】:
-
在 CMake GUI 中,尝试选择生成器“Visual Studio 14 2015 Win64”而不是“Visual Studio 14 2015”或相反。
-
我将生成器从“Visual Studio 14 2015 Win64”更改为“Visual Studio 14 2015”。我收到一个错误:
1>------ Build started: Project: vsal, Configuration: Release Win32 ------ 1>opencv_highgui320.lib(opencv_highgui320.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' 2>------ Build started: Project: vsal_player, Configuration: Release Win32 ------ 2>LINK : fatal error LNK1181: cannot open input file '..\lib\Release\vsal.lib' ========== Build: 0 succeeded, 2 failed, 2 up-to-date, 0 skipped ========== -
我明白了。如果我没看错,您的 Boost 库是在 32 位模式下编译的,而您的 OpenCV 库是在 64 位模式下编译的。 vsal 库需要两者,这是一个问题。我建议以 64 位模式重新编译您的 Boost 库。
-
这是正确的解决方案。我所要做的就是运行
.\b2 address-model=64命令。非常感谢! -
太棒了!我会添加这个作为答案。
标签: c++ visual-studio boost visual-studio-2015 cmake