MAC: Clion configure C compiler Error: The C compiler identification is unknown

1 click let cmake detect

View error message:
/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):xxxx(can not find /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/core/include:)

2 view environment variables

cd ~
vim .bash_profile

It is found that the error path is cflags (I wonder why I set cflags to be a python library?) Solution: comment out this line of code. Result: Although there is no error message in red in this interface, the program still cannot be compiled

Replace c compiler [key to solving the problem]

View all gcc compiler paths

brew list gcc
/usr/local/Cellar/gcc/11.2.0/bin/c++-11
/usr/local/Cellar/gcc/11.2.0/bin/cpp-11
/usr/local/Cellar/gcc/11.2.0/bin/g++-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-ar-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-nm-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-ranlib-11
/usr/local/Cellar/gcc/11.2.0/bin/gcov-11
/usr/local/Cellar/gcc/11.2.0/bin/gcov-dump-11
/usr/local/Cellar/gcc/11.2.0/bin/gcov-tool-11
/usr/local/Cellar/gcc/11.2.0/bin/gdc
/usr/local/Cellar/gcc/11.2.0/bin/gdc-11
/usr/local/Cellar/gcc/11.2.0/bin/gfortran
/usr/local/Cellar/gcc/11.2.0/bin/gfortran-11
/usr/local/Cellar/gcc/11.2.0/bin/lto-dump-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-c++-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-g++-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-11.2.0
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-ar-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-nm-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-ranlib-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gdc-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gfortran-11
/usr/local/Cellar/gcc/11.2.0/include/c++/ (796 files)
/usr/local/Cellar/gcc/11.2.0/lib/gcc/ (1304 files)
/usr/local/Cellar/gcc/11.2.0/libexec/gcc/ (15 files)
/usr/local/Cellar/gcc/11.2.0/share/gcc-11.2.0/ (4 files)
/usr/local/Cellar/gcc/11.2.0/share/man/ (12 files)

C compiler and C + + compiler use respectively:

/usr/local/Cellar/gcc/11.2.0/bin/gcc-11
/usr/local/Cellar/gcc/11.2.0/bin/g++-11

After selection, Clion automatically compiles and succeeds.


Read More: