破碎CMake和OSX
下GCC当cmake-gui
我的OSX平台上运行configure
,我碰到下面的错误发生的历史:破碎CMake和OSX
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>
从看互联网上的论坛等,我已经建立,这可能是用我的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这个路径变量最近已改变,我认为,海湾合作委员会的问题必须在相同的排序时间如雨后春笋般涌现。我的系统安装出现这种情况可能会出现什么问题?
一些更多的细节。由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的2.8.2,这是相当古老,据CMake的版本去。尝试使用2.8.11或即将发布的2.8.12的候选版本,以查看问题是否仍然存在。如果没有别的,也许你会得到更好的错误信息。
看到这个问题,答案及链接查看关于保证通过Mac上的其他手段发动命令行环境和GUI应用程序之间是一致的路径值的各种方法:https://serverfault.com/questions/16355/how-to-set-global-path-on-os-x/277034
CMake的GUI并不一定继承与您在终端中看到的相同的PATH值,除非您使用打开的命令从终端启动它。
在我这里弹出另外两个东西:gcc 4.0是C编译器,但g ++ 4.2是C++编译器。为什么这些不同?
另外,CMAKE_MAKE_PROGRAM指向/ opt/local/bin/gmake。这两个构建树都是如此吗? (命令行一和gui一样?)看起来好奇的是,CMake会从/ usr/bin获取C和C++编译器,但从/ opt/local/bin获取gmake ...
是您的命令行环境仔细设置,以使用这些路径中的这些工具?或者这对你来说也是意想不到的?
你没有提到你使用的Xcode工具的版本。也许在你的问题中加入这个问题有助于更好地回答某人的大脑。
最后一个观察:你的PATH中有很多东西。最大限度地减少在构建环境中使用的PATH值可以帮助您避免这样的问题。我衷心推荐将其剥离到最低限度,至少在软件构建环境中是这样。
对不起,我不回答的答案,但有一点评论似乎有点过分了堆栈溢出评论... :-)
感谢您的详细解答!你已经添加了很多细节和知识。我认为最终我的系统非常糟糕,而且我已经完成了一个完整的系统重装,这有助于理顺很多东西! – 2013-09-10 09:54:38
我也碰到过这样的问题,我已经设置了正确的固定它CXXFLAGS和CPPFLAGS。我想你也应该检查一下。
一个简单的解决办法是:
CPPFLAGS := $(CPPFLAGS) $(CFLAGS) CXXFLAGS := $(CXXFLAGS) $(CFLAGS)
或者你应该检查你的路径是否正确。您应该能够在当前shell中找到CXX编译器和C编译器。
失败的编译测试的输出可能是该日志中最有用的信息。 – Mat 2013-05-09 15:52:21
谢谢,我已经包含了完整的CMake输出。它看起来像也许创建的对象文件不能正常工作? – 2013-05-09 15:58:13
然后检查你的安装binutils – bikram990 2013-05-10 05:51:29