解决Mac OS平台上CLion编译失败问题 “-- The C compiler identification is unknown”

    科技2022-08-10  113

    /Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/apple/CLionProjects/untitled16 -- 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): The C compiler "/usr/bin/cc" is not able to compile a simple test program. It fails with the following output: Change Dir: /Users/apple/CLionProjects/untitled16/cmake-build-debug/CMakeFiles/CMakeTmp Run Build Command(s):/usr/bin/make cmTC_09f20/fast && xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

    尽管Xcode下能编译但是CLion还会报错,以上为CLion报错内容,经过查找后发现其实是Command Line Tools工具出现问题。重新下载Command Line Tools后即可,常用的方法是在终端命令行输入xcode-select --install方法,但是该方法经常无法连接到更新服务器的问题。

    所以推荐去苹果开发者官网去下载Command Line Tools 

    https://developer.apple.com/download/more/

     

    下载后安装pkg文件即可

    恢复正常

    Processed: 0.027, SQL: 8