【发布时间】:2017-11-15 09:34:52
【问题描述】:
我尝试让 clang 5.0.0 为 Visual Studio 2015 工作,因为我需要 OpenMP 3.0 功能。我安装了clang编译器(不是没有任何openmp支持的vs2015版本)并使用cmake:
cmake_minimum_required(VERSION 2.8.10)
project(myproject)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
include_directories("include")
add_library(libFoo STATIC Foo.cpp)
install(TARGETS Foo libFoo LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
当我现在尝试使用或不使用工具链 LLVM-vs2014 配置 MSVC 14 2015 Win64 构建时,我总是收到一个错误,即找不到 OpenMP:
The C compiler identification is Clang 5.0.0
The CXX compiler identification is Clang 5.0.0
Check for working C compiler: D:/Program Files/LLVM/msbuild-bin/cl.exe
Check for working C compiler: D:/Program Files/LLVM/msbuild-bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: D:/Program Files/LLVM/msbuild-bin/cl.exe
Check for working CXX compiler: D:/Program Files/LLVM/msbuild-bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) (found version "1.0")
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) (found version "1.0")
Configuring done
使用的编译器似乎是正确的(安装 clang,而不是 Microsoft 版本),它自动检测 clang-cl 二进制文件,但 OpenMP 失败。 我尝试使用“指定本机编译器”手动指定编译器并获得相同的结果。它甚至选择了 clang-cl 版本而不是 clang++。
没有解决问题的相关答案:
- Compiling C code with openmp using clang-cl - 最近的 clang 包含了 libomp.lib 和 libiomp5.dll
【问题讨论】:
-
我在stackoverflow.com/a/68378031/7268445 发布的答案可能会对未来的读者有所帮助
标签: c++ visual-studio-2015 clang openmp