Windows上的Clang和CMake - clang.exe坏了,程序不可执行

时间:2014-06-06 04:38:06

标签: c++ windows cmake clang

我在Windows上设置了Clang和CMake,当在OpenSceneGraph项目源(配置步骤)上运行cmake-gui时,该过程失败并显示Check for working C compiler: C:/Program Files (x86)/LLVM/bin/clang.exe -- broken

跟随整个输出:

The C compiler identification is unknown
The CXX compiler identification is unknown
Found Eclipse version 4.3 ()
Check for working C compiler: C:/Program Files (x86)/LLVM/bin/clang.exe
Check for working C compiler: C:/Program Files (x86)/LLVM/bin/clang.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "C:/Program Files (x86)/LLVM/bin/clang.exe" is not able to
  compile a simple test program.

  It fails with the following output:

   Change Dir: C:/Users/Adam/Desktop/OpenSceneGraph-3.2.1-rc3/build/CMakeFiles/CMakeTmp



  Run Build Command:C:/PROGRA~2/GnuWin32/bin/make.exe
  "cmTryCompileExec2091697540/fast"

  C:/PROGRA~2/GnuWin32/bin/make.exe -f
  CMakeFiles/cmTryCompileExec2091697540.dir/build.make
  CMakeFiles/cmTryCompileExec2091697540.dir/build


  make.exe[1]: Entering directory
  `C:/Users/Adam/Desktop/OpenSceneGraph-3.2.1-rc3/build/CMakeFiles/CMakeTmp'



  "C:/Program Files (x86)/CMake/bin/cmake.exe" -E cmake_progress_report
  C:/Users/Adam/Desktop/OpenSceneGraph-3.2.1-rc3/build/CMakeFiles/CMakeTmp/CMakeFiles
  1


  "Building C object
  CMakeFiles/cmTryCompileExec2091697540.dir/testCCompiler.c.obj"


  "C:/Program Files (x86)/LLVM/bin/clang.exe" -o
  CMakeFiles/cmTryCompileExec2091697540.dir/testCCompiler.c.obj -c
  C:/Users/Adam/Desktop/OpenSceneGraph-3.2.1-rc3/build/CMakeFiles/CMakeTmp/testCCompiler.c



  clang.exe: error: unable to execute command: program not executable

  clang.exe: error: assembler (via gcc) command failed with exit code 1 (use
  -v to see invocation)

  make.exe[1]: ***
  [CMakeFiles/cmTryCompileExec2091697540.dir/testCCompiler.c.obj] Fehler 1


  make.exe[1]: Leaving directory
  `C:/Users/Adam/Desktop/OpenSceneGraph-3.2.1-rc3/build/CMakeFiles/CMakeTmp'



  make.exe: *** [cmTryCompileExec2091697540/fast] Fehler 2






  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:47 (PROJECT)


Configuring incomplete, errors occurred!
See also "C:/Users/Adam/Desktop/OpenSceneGraph-3.2.1-rc3/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Adam/Desktop/OpenSceneGraph-3.2.1-rc3/build/CMakeFiles/CMakeError.log".

这可能是什么原因?程序之间是否存在不兼容性,或者是否缺少环境变量?

4 个答案:

答案 0 :(得分:0)

您的clang安装是否已损坏/未完成,或者可能是cmake bug。首先检查你是否能够编译" hello world"直接用clang(没有cmake)

答案 1 :(得分:0)

您需要确保将Visual Studio生成器与clang

的正确工具集一起使用

http://public.kitware.com/Bug/view.php?id=14863

我不知道cmake-gui是否有办法设置工具集,所以请尝试使用命令行。

cmake.exe .. -T LLVM-vs2010

答案 2 :(得分:0)

确保您的sdk方向没有某些特殊字符,例如:'(',')',''。 通过.txt阅读器检查日志。日志位于.externalNativeBuild / cmake / debug /...

答案 3 :(得分:0)

如本link所述,Windows上的 clang 必须能够找到 link.exe

我使用旧的Visual Studio Express版本链接器对其进行了测试,并且效果很好。