Cmake不工作。 C编译器失败

时间:2015-10-09 17:44:19

标签: macos cmake

我正在尝试在osx 10.11上安装一个库但是当我使用cmake时,它会打印下面的输出。这在过去是有效的(就像昨天一样),但从那时起似乎出现了问题。我找了一个答案,但似乎找不到任何有用的东西。我的Xcode和Xcode命令行工具都是最新的。我的cmake是最新的。我尝试卸载并重新安装它无济于事。我已经测试了c编译器,据我所知它应该正常工作。我的openssl也是最新的,我尝试重新安装它也没有成功。我的Clang版本是7.0.0(clang-700.0.72)。我很遗憾可能是显而易见的事情。任何想法将不胜感激。

$ pwd
<*current directory*>
$ mkdir build
$ cd build
$ cmake ..

-- The C compiler identification is AppleClang 7.0.0.7000072
-- The CXX compiler identification is AppleClang 7.0.0.7000072
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- broken
CMake Error at /usr/local/Cellar/cmake/3.3.2/share/cmake/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler
  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: <*current directory*>/build/CMakeFiles/CMakeTmp



  Run Build Command:"/usr/bin/make" "cmTC_e9215/fast"

  /Applications/Xcode.app/Contents/Developer/usr/bin/make -f
  CMakeFiles/cmTC_e9215.dir/build.make CMakeFiles/cmTC_e9215.dir/build

  Building C object CMakeFiles/cmTC_e9215.dir/testCCompiler.c.o


  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
  -o CMakeFiles/cmTC_e9215.dir/testCCompiler.c.o -c

  <*current directory*>/build/CMakeFiles/CMakeTmp/testCCompiler.c


  Linking C executable cmTC_e9215

  /usr/local/Cellar/cmake/3.3.2/bin/cmake -E cmake_link_script
  CMakeFiles/cmTC_e9215.dir/link.txt --verbose=1


  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
  -Wl,-search_paths_first -Wl,-headerpad_max_install_names
  /usr/local/opt/openssl/lib CMakeFiles/cmTC_e9215.dir/testCCompiler.c.o -o
  cmTC_e9215

  ld: can't map file, errno=22 file '/usr/local/opt/openssl/lib' for
  architecture x86_64

  clang: error: linker command failed with exit code 1 (use -v to see
  invocation)

  make[1]: *** [cmTC_e9215] Error 1

  make: *** [cmTC_e9215/fast] Error 2





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


-- Configuring incomplete, errors occurred!
See also "<*current directory*>/build/CMakeFiles/CMakeOutput.log".
See also "<*current directory*>/build/CMakeFiles/CMakeError.log".

这是&lt; 当前目录&gt; /build/CMakeFiles/CMakeOutput.log的输出:

The system is: Darwin - 15.0.0 - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
Build flags:
Id flags:

The output was:
0


Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"

The C compiler identification is AppleClang, found in "<*current directory*>/build/CMakeFiles/3.3.2/CompilerIdC/a.out"

Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
Build flags:
Id flags:

The output was:
0


Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"

The CXX compiler identification is AppleClang, found in "<*current directory*>/build/CMakeFiles/3.3.2/CompilerIdCXX/a.out"

这是&lt; 当前目录&gt; /build/CMakeFiles/CMakeError.log的输出:

Determining if the C compiler works failed with the following output:
Change Dir: <*current directory*>/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_e9215/fast"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_e9215.dir/build.make CMakeFiles/cmTC_e9215.dir/build
Building C object CMakeFiles/cmTC_e9215.dir/testCCompiler.c.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang    -o CMakeFiles/cmTC_e9215.dir/testCCompiler.c.o   -c <*current directory*>/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_e9215
/usr/local/Cellar/cmake/3.3.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e9215.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang    -Wl,-search_paths_first -Wl,-headerpad_max_install_names  /usr/local/opt/openssl/lib  CMakeFiles/cmTC_e9215.dir/testCCompiler.c.o  -o cmTC_e9215
ld: can't map file, errno=22 file '/usr/local/opt/openssl/lib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_e9215] Error 1
make: *** [cmTC_e9215/fast] Error 2

修改 简单的重启似乎解决了它。我应该首先尝试的明显答案。抱歉浪费你的时间

1 个答案:

答案 0 :(得分:0)

错误为ld: can't map file, errno=22 file '/usr/local/opt/openssl/lib' for architecture x86_64。在我看来,这是一个目录,而不是一个文件。您可以在上面的行上运行cmake命令,并尝试在前面添加-L