【发布时间】:2013-05-09 15:49:41
【问题描述】:
在我的 OS X 平台上以 cmake-gui 运行 configure 时,出现以下错误:
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.c.o
/usr/bin/gcc-4.0 -isysroot -o
CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c
/Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp/testCCompiler.c
i686-apple-darwin10-gcc-4.0.1:
CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o: No such file or
directory
<snip>
通过查看 Internet 上的论坛等,我确定这可能与我的 PATH 变量有关。这是我用于分析的 PATH 变量:
! 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
这个路径变量最近在我配置 Python 时发生了变化,我认为 GCC 问题一定是同时出现的。我的系统安装可能有什么问题导致这种情况发生?
更多细节。 CMAKE_MAKE_PROGRAM指定的构建程序是/opt/local/bin/gmake。
我还发现只有在cmake-gui 中运行Configure 时才会抛出这些错误。在命令行上(从构建文件夹运行cmake ..),配置完成:
! 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
但是,在使用某些库时编译并不总是成功 - 参见例如 this question I have asked here。因此,我认为cmake 进程中可能仍有问题。
【问题讨论】:
-
编译测试失败的输出可能是该日志中最有用的信息。
-
谢谢,我已经包含了完整的 CMake 输出。看起来目标文件的创建可能无法正常工作?
-
然后检查你的 binutils 安装
-
这是什么 OSX 和 XCode 版本? /usr/bin/gcc-4.0 -isysroot -o CMakeFiles/cmTryCompileExec.dir/testCCompiler.co -c /Users/bill/Desktop/cmake_test/build/CMakeFiles/CMakeTmp/testCCompiler.c 实际上给出了什么?
-
请考虑您使用的 GCC 版本 4.0,已有 8 年历史(2005 年)。检查您使用的库是否与该版本兼容。考虑将编译器升级到 GCC 4.8 或 Clang 3.3。