Clion cannot recognize any header files or keywords


Hi, my code was running perfectly yesterday on Clion and today I opened it up again and it stopped working. Basically, Clion just says that all headers aren't found. You can see it here:


It also says keywords like ‘cout’ or ‘cerr’ are undeclared identifiers. 

Then, I found the file clion-Debug-log.txt, which looked like this: 

/Applications/ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/Applications/ -G Ninja -S /Users/wmm/CLionProjects/untitled2 -B /Users/wmm/CLionProjects/untitled2/cmake-build-debug
-- 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/ (message):
  The C compiler
  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/ -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.

    ninja: build stopped: subcommand failed.
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!

Apparently, the error occurred because I didn't agree to the Xcode license agreements. I went ahead and run ‘sudo xcodebuild -license’ within my terminal and agreed to the license. Then I closed clion and opened it again, and the error was still there for some reason. I then reinstalled Clion, but that still didn't fix the error. Do you have an idea why this is happening? How do I fix it. Thanks



Does it help if you do `Tools | CMake | Reset Cache and Reload Project` in CLion after running ‘sudo xcodebuild -license’ in Terminal?


Yeah, it works now. Thank you


Please sign in to leave a comment.