I was using Clion perfectly yesterday, but today, I opened Clion again and Clion cannot recognize any header files and keywords. It just says the header files don't exist and the keywords are "undeclared identifiers." You can see the error in this image:
Then, I looked at the file clion-Debug-log.txt:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- 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.26/Modules/CMakeTestCCompiler.cmake:67 (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/wmm/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-kdTUik
Run Build Command(s):/Applications/CLion.app/Contents/bin/ninja/mac/ninja -v cmTC_7d28b && [1/2] /usr/bin/cc -arch arm64 -o CMakeFiles/cmTC_7d28b.dir/testCCompiler.c.o -c /Users/wmm/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-kdTUik/testCCompiler.c
FAILED: CMakeFiles/cmTC_7d28b.dir/testCCompiler.c.o
/usr/bin/cc -arch arm64 -o CMakeFiles/cmTC_7d28b.dir/testCCompiler.c.o -c /Users/wmm/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-kdTUik/testCCompiler.c
You have not agreed to the Xcode license agreements. Please run 'sudo xcodebuild -license' from within a Terminal window to review and agree to the Xcode and Apple SDKs license.
Basically, it says the error is caused because I didn't agree to the conditions of the Xcode license. So, I followed the instruction given and entered sudo xcodebuild -license
into my terminal. I agreed to the license, then reopened Clion, and the error is still there. I also reinstalled Clion, but the error persists.
I copy pasted parts of the message from the clion-Debug-log.txt file in google, but google says there are no results for this.
Does anyone know what is causing this error? Thank you so much!
It turns out I just had to 'Tools | CMake | Reset Cache and Reload Project' in CLion after agreeing to the Xcode license. Now it works fine.