2013-05-09 75 views
4

下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過程中可能仍然存在問題。

+0

失敗的編譯測試的輸出可能是該日誌中最有用的信息。 – Mat 2013-05-09 15:52:21

+0

謝謝,我已經包含了完整的CMake輸出。它看起來像也許創建的對象文件不能正常工作? – 2013-05-09 15:58:13

+0

然後檢查你的安裝binutils – bikram990 2013-05-10 05:51:29

回答

3

你的問題的一些觀察,這可能導致你的解決方案......

您使用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值可以幫助您避免這樣的問題。我衷心推薦將其剝離到最低限度,至少在軟件構建環境中是這樣。

對不起,我不回答的答案,但有一點評論似乎有點過分了堆棧溢出評論... :-)

+0

感謝您的詳細解答!你已經添加了很多細節和知識。我認爲最終我的系統非常糟糕,而且我已經完成了一個完整的系統重裝,這有助於理順很多東西! – 2013-09-10 09:54:38

0

我也碰到過這樣的問題,我已經設置了正確的固定它CXXFLAGS和CPPFLAGS。我想你也應該檢查一下。

一個簡單的解決辦法是:

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

或者你應該檢查你的路徑是否正確。您應該能夠在當前shell中找到CXX編譯器和C編譯器。