我試圖運行這個簡單的CMake命令:CMake的(2.8.12.2)在Ubuntu 14.04編譯器檢查失敗
$ cmake -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++ ./src/
我得到以下輸出:
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message): The C compiler "/usr/bin/gcc" is not able to compile a simple test program.
的原因錯誤是:
gcc: error: unrecognized command line option ‘-rpath’
因爲CMake的是試圖用下面的命令鏈接:
/usr/bin/gcc -rpath /usr/local/openblas/lib CMakeFiles/cmTryCompileExec1190183239.dir/testCCompiler.c.o -o cmTryCompileExec1190183239 -rdynamic
據我所知,gcc沒有單獨的'-rpath'選項。我不確定爲什麼CMake正在嘗試這樣做。
還有其他人遇到過嗎?解決方案?
謝謝!
PS:一些更多的信息,或許有用: 我想學習如何使用CMake的這樣的目錄結構非常簡單:
-cmake_test/
-bin/
-src/
-executable.cpp
-CMakeLists.txt
-CMakeLists.txt
編輯:
完整輸出
$ cmake ./src/
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp
Run Build Command:/usr/bin/make "cmTryCompileExec961681416/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec961681416.dir/build.make
CMakeFiles/cmTryCompileExec961681416.dir/build
make[1]: Entering directory
`/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp/CMakeFiles
1
Building C object
CMakeFiles/cmTryCompileExec961681416.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTryCompileExec961681416.dir/testCCompiler.c.o
-c
/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTryCompileExec961681416
/usr/bin/cmake -E cmake_link_script
CMakeFiles/cmTryCompileExec961681416.dir/link.txt --verbose=1
/usr/bin/cc -rpath /usr/local/openblas/lib
CMakeFiles/cmTryCompileExec961681416.dir/testCCompiler.c.o -o
cmTryCompileExec961681416 -rdynamic
cc: error: unrecognized command line option ‘-rpath’
make[1]: *** [cmTryCompileExec961681416] Error 1
make[1]: Leaving directory
`/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeTmp'
make: *** [cmTryCompileExec961681416/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
-- Configuring incomplete, errors occurred!
See also "/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeOutput.log".
See also "/home/gyorgy/Workspace/CPP_Tests/src/cmake_test/CMakeFiles/CMakeError.log".
如果你輸入一個簡單的命令,如* $ cmake ./src/*,你會得到錯誤嗎?你能寫出完整的輸出嗎? – fenix688 2014-11-25 09:56:47
感謝您的回覆。我犯了同樣的錯誤。我已經用$ cmake的完整輸出更新了原始文章./src/ – George 2014-11-25 22:57:41
在刪除編譯器配置後,出現相同的錯誤是正常的。 CMake使用緩存系統來保存以前配置的信息。請刪除CMakeCache.txt文件並重新運行'cmake。/ src' – Antwane 2014-11-26 10:51:52