Broken CMake and gcc under OSX

When running configure in cmake-gui on my OSX platform, the following error occurs:

 The C compiler identification is GNU The CXX compiler identification is GNU Checking whether C compiler has -isysroot Checking whether C compiler has -isysroot - yes Checking whether C compiler supports OSX deployment target flag Checking whether C compiler supports OSX deployment target flag - yes Check for working C compiler: /usr/bin/gcc-4.0 Check for working C compiler: /usr/bin/gcc-4.0 -- broken CMake Error at /Applications/CMake 2.8-2.app/Contents/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE): The C compiler "/usr/bin/gcc-4.0" is not able to compile a simple test program. It fails with the following output: Change Dir: /Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp Run Build Command:/opt/local/bin/gmake "cmTryCompileExec/fast" /opt/local/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make CMakeFiles/cmTryCompileExec.dir/build gmake[1]: Entering directory `/Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp' "/Applications/CMake 2.8-2.app/Contents/bin/cmake" -E cmake_progress_report /Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp/CMakeFiles 1 Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.co /usr/bin/gcc-4.0 -isysroot -o CMakeFiles/cmTryCompileExec.dir/testCCompiler.co -c /Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp/testCCompiler.c i686-apple-darwin10-gcc-4.0.1: CMakeFiles/cmTryCompileExec.dir/testCCompiler.co: No such file or directory <snip> 

From looking at forums, etc. I found on the Internet that this could be due to my PATH variable. Here is my PATH variable for analysis:

 ! echo $PATH /Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/sw/bin:/sw/sbin:/Applications/MATLAB_R2012a.app/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin 

This path variable recently changed when I configured Python, and I think gcc problems should be occurring at the same time. What could be wrong in my system installation for this?


Some details. The build program specified by CMAKE_MAKE_PROGRAM is /opt/local/bin/gmake .

I also found that these errors are only generated when configure run in cmake-gui . On the command line (starting cmake .. from the build folder), the configuration completes normally:

 ! cmake .. -- The C compiler identification is GNU 4.0.1 -- The CXX compiler identification is GNU 4.2.1 -- Checking whether C compiler has -isysroot -- Checking whether C compiler has -isysroot - yes -- Checking whether C compiler supports OSX deployment target flag -- Checking whether C compiler supports OSX deployment target flag - yes -- Check for working C compiler: /usr/bin/gcc-4.0 -- Check for working C compiler: /usr/bin/gcc-4.0 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Checking whether CXX compiler has -isysroot -- Checking whether CXX compiler has -isysroot - yes -- Checking whether CXX compiler supports OSX deployment target flag -- Checking whether CXX compiler supports OSX deployment target flag - yes -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done 

However, compilation is not always successful when using some libraries - see, for example, this question that I asked here . Therefore, I think that something may be wrong with the cmake process.

+4
source share
2 answers

Some notes about your question that may lead to a solution ...

You are using CMake 2.8.2, which is pretty old as far as CMake versions go. Try using 2.8.11 or a candidate for the upcoming 2.8.12 release to see if a problem exists. If nothing else, you may receive an error message.

See this question and answer and its links for different ways to ensure consistent PATH values ​​between command-line environments and gui applications launched by other means on a Mac: https://serverfault.com/questions/16355/how-to-set -global-path-on-os-x / 277034

CMake gui does not necessarily inherit the same PATH value, as you see in your terminal, unless you started it from the terminal using the open command.

Two other things come to me here: gcc 4.0 is a C compiler, but g ++ 4.2 is a C ++ compiler. Why are these different?

In addition, CMAKE_MAKE_PROGRAM points to / opt / local / bin / gmake. Is this true in both build trees? (Is the command line one and the same?) I find it curious that CMake compiled C and C ++ compilers from / usr / bin, but gmake from / opt / local / bin ...

Is your command-line environment carefully configured to use these very tools from these paths? Or is it also unexpected for you?

You do not mention which version of Xcode tools you use at all. Perhaps adding that to your question will help to better answer in someone's brain.

Last observation: you have many things in your PATH. Minimizing the PATH value that you use in your build environments will help you avoid such problems. I wholeheartedly recommend stripping to the minimum you need, at least for the software development environment.

Sorry for the unanswered answer, but this comment is too revealing for the comment ... :-)

+3
source

I also ran into this problem, I fixed it by installing the correct CXXFLAGS and CPPFLAGS. I think you should also check this out.

One simple solution:

CPPFLAGS := $(CPPFLAGS) $(CFLAGS) CXXFLAGS := $(CXXFLAGS) $(CFLAGS)

Or you should check the correctness of your PATH. You should be able to find the CXX compiler and the C compiler in your current shell.

0
source

Source: https://habr.com/ru/post/1479945/


All Articles