Clion doesnt compile on MacOS Sierra

After I updated my macOS to 10.12 sierra, Clion cant compile, debug or run my projects. I already tried to reinstall and search in the forum for some solution but I could not resolve this problem.


Here is my error log:

Error:The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/juniorlima/Library/Caches/CLion2016.2/cmake/generated/lesk-e04046c3/e04046c3/__default__/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_ab383/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.
Error:Configuration Debug
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/juniorlima/Library/Caches/CLion2016.2/cmake/generated/lesk-e04046c3/e04046c3/Debug/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_4c8ea/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.
Error:Configuration Release
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/juniorlima/Library/Caches/CLion2016.2/cmake/generated/lesk-e04046c3/e04046c3/Release/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_d38b8/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.
Error:Configuration RelWithDebInfo
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/juniorlima/Library/Caches/CLion2016.2/cmake/generated/lesk-e04046c3/e04046c3/RelWithDebInfo/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_67d49/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.
Error:Configuration MinSizeRel
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/juniorlima/Library/Caches/CLion2016.2/cmake/generated/lesk-e04046c3/e04046c3/MinSizeRel/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_d2011/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.
2

Hi Alimaj.

Please re-install Xcode developer tools via 

xcode-select --install

in terminal.

8
Avatar
Permanently deleted user

Hello!

Thanks a lot Anna Filippova.

I have been struggling with that error for about 1 week. Now it is working.

Best regards,

Roger

0
Avatar
Permanently deleted user

Hello!

I've got the same problems with Alimaj's after upgrading MacOS X to Sierra.

But it didn't help to try the command that Anna provided. The error is still the same as below, anyone can help?

/Applications/CLion.app/Contents/bin/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/zhiyuanwang/ClionProjects/test
-- 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/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (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/zhiyuanwang/ClionProjects/test/cmake-build-debug/CMakeFiles/CMakeTmp



Run Build Command:"/usr/bin/make" "cmTC_e0a89/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/zhiyuanwang/ClionProjects/test/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/Users/zhiyuanwang/ClionProjects/test/cmake-build-debug/CMakeFiles/CMakeError.log".

[Previous CMake output restored: 12/10/16, 4:22 PM]

 

2

@Wangzhiy

I had the same problem. For me, the fix was to agree to the xcode license. To do that, open up a terminal and enter the following command:

sudo xcodebuild -license

Once you've entered your sudo password the license will then be presented on screen, hit the space bar to scroll through the text. When you get to the end of the text, you'll be prompted to enter 'agree', type this in, and then, back in CLion, click on File->Reload CMake Project and everything should work. 

Good luck.

Cheers

Barry

8
Avatar
Permanently deleted user

I had the same problem, and it worked only after I did both steps.
Thank you very much Anna and Barry.
Nadav

0
Avatar
Permanently deleted user

This also solves the problem where you can make the project from the command line, but CLion cant with this error 

/Library/Developer/CommandLineTools/usr/bin/c++: Permission denied clion

Thank you Barry

0

Hi. My issue is after I remove Xcode. But I still do have Command Line Tools, which include all the necessary compilers such as clang, gcc. The error that I read is the following:

/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/hsl/CLionProjects/Test_sololearn/cmake-build-debug --target untitled -- -j 2
Scanning dependencies of target untitled
[ 50%] Building CXX object CMakeFiles/untitled.dir/main.cpp.o
make[3]: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++: No such file or directory
make[3]: *** [CMakeFiles/untitled.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/untitled.dir/all] Error 2
make[1]: *** [CMakeFiles/untitled.dir/rule] Error 2
make: *** [untitled] Error 2

I would appreciate some help.

0
Avatar
Permanently deleted user

Hi 

 

what solved the problem for me was to install & open XCODE, and afterwards to agree to software requirements. 

Apparently XCODE makes some difference on macOS for C & C++ programming... 

0

So many thank for Anna and Barry, I solved this problem by completing both steps, just one tip, when terminal ask you to enter the sudo password, that's the password you used to open your Macbook

0

请先登录再写评论。