首页 > 解决方案 > Macbook更新后Clion编译器无法正常工作?

问题描述

我的 CLion 不允许我在下面使用此消息进行编译。有任何解决这个问题的方法吗?

/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/name/CLionProjects/untitled118
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
 message(FATAL_ERROR "The C compiler\n  \"${CMAKE_C_COMPILER}\"\n"

  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/name/CLionProjects/untitled118/cmake-build-debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make cmTC_5c666/fast && xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    
    

  

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


-- Configuring incomplete, errors occurred!
See also "/Users/name/CLionProjects/untitled118/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/Users/name/CLionProjects/untitled118/cmake-build-debug/CMakeFiles/CMakeError.log".

标签: c++cmakeclion

解决方案


您缺少命令行工具。在更新 XCode 和/或 macOS 后,这种情况经常发生。旧版本的工具将被删除,但不会安装新工具。解决此问题的方法是:

  1. 按照最新版本 XCode 的说明安装命令行工具。这可以通过命令行以及通过 XCode 的首选项来完成。
  2. 从 CLion 清理并重建 CMake 项目,以便根据最新路径重新生成 Makefile。

推荐阅读