3

I have installed gcc and g++ instead of clang compilers from Xcode, so now I have problem with compiling with cmake. After running cmake I have got error:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- broken
CMake Error at /usr/local/Cellar/cmake/3.15.3/share/cmake/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/usr/bin/gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/yuriy/Projects/SublimeProjects/AgingAlgorithm/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/make cmTC_d5a2e/fast && xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
    Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
    See `man xcode-select` for more details.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:6 (project)


-- Configuring incomplete, errors occurred!
See also "/Users/yuriy/Projects/SublimeProjects/AgingAlgorithm/build/CMakeFiles/CMakeOutput.log".
See also "/Users/yuriy/Projects/SublimeProjects/AgingAlgorithm/build/CMakeFiles/CMakeError.log".

Problem have been appeared after deleting clang compilers and Xcode and changing links cc, c++, gcc and g++. In terminal macOS can run utilities gcc, cc, g++, c++, but it still doesn't work for cmake.

Can I fix it without installation of basic clang compilers from Xcode? If I can, so how?

1

Assuming you installed gcc using brew, run brew info gcc. Find the path similar to /usr/local/Cellar/gcc/9.2.0. Go the that directory and find gcc file in bin. Copy the path name and paste it in Cmake (assuming GUI) as follows.

After cleaning cache in File -> Delete cache, start afresh in Tools -> Configure. Specify "Unix Makefiles" instead of Xcode and select "Specify native compilers."

Cmake Configuration

In the compilers for C and C++, copy the full path found above. Similar to /usr/local/Cellar/gcc/9.2.0/bin/gcc-9.

compiler specification

And then try configuring. And update me with the log afterwards.

| improve this answer | |
  • I have fixed this problem by reseting path. So, it was hard for solve it until the moment when I have seen offer from cmake to reset: "sudo xcode-select --switch / " - it works fine for me, but nevertheless you must to set compilers inside cmake file: "set(CMAKE_C_COMPILER gcc) and set(CMAKE_CXX_COMPILER g++)" – yurec_wtf Oct 2 '19 at 10:55
  • you could write an answer too! glad you solved it. – anki Oct 2 '19 at 11:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .