Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gcc Ubuntu 14.04上的CMake(2.8.12.2)编译器检查失败_Gcc_Cmake_Ubuntu 14.04 - Fatal编程技术网

Gcc Ubuntu 14.04上的CMake(2.8.12.2)编译器检查失败

Gcc Ubuntu 14.04上的CMake(2.8.12.2)编译器检查失败,gcc,cmake,ubuntu-14.04,Gcc,Cmake,Ubuntu 14.04,我正在尝试运行这个简单的CMake命令: $ cmake -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++ ./src/ 我得到以下输出: --C编译器标识为GNU4.8.2 --CXX编译器标识为GNU 4.8.2 --检查C编译器是否工作:/usr/bin/gcc --检查C编译器是否工作:/usr/bin/gcc——已损坏 CMake错误位于/usr/share/CMake-2.8/Modules/CM

我正在尝试运行这个简单的CMake命令:

$ cmake -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++ ./src/
我得到以下输出:

--C编译器标识为GNU4.8.2

--CXX编译器标识为GNU 4.8.2

--检查C编译器是否工作:/usr/bin/gcc

--检查C编译器是否工作:/usr/bin/gcc——已损坏

CMake错误位于/usr/share/CMake-2.8/Modules/CMakeTestCCompiler。CMake:61(消息): C编译器“/usr/bin/gcc”无法编译简单的测试程序

错误原因如下:

gcc:错误:无法识别的命令行选项'-rpath'

因为CMake正在尝试使用以下命令链接:

/usr/bin/gcc-rpath/usr/local/openblas/lib cmakfiles/cmTryCompileExec1190183239.dir/testCCompiler.c.o-o cmTryCompileExec1190183239-rdynamic

据我所知,gcc没有独立的“-rpath”选项。我不知道为什么CMake要这么做

还有其他人遇到过这个吗?解决方案

谢谢

PS:更多有用的信息: 我正在尝试学习如何使用CMake,因此目录结构非常简单:

-cmake_测试/
-bin/
-src/
-可执行文件.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".

我向大家道歉。。。这个错误是因为我刚才犯了一个错误

简而言之,我的.bashrc文件中有以下不正确的行:

export-LDFLAGS=“-rpath/usr/local/openblas/lib”$LDFLAGS

CMake在CMakeCommonLanguageInclude.CMake模块中有以下行:

set(CMAKE_EXE_LINKER_FLAGS“${CMAKE_EXE_LINKER_FLAGS_INIT}$ENV{LDFLAGS}”

这显然导致将CMAKE_EXE_LINKER_标志设置为
-rpath/usr/local/openblas/lib
,并且 因此出现错误。将.bashrc文件更改为:

export-LDFLAGS=“-Wl,-rpath=/usr/local/openblas/lib”$LDFLAGS

问题解决了

我不知道为什么这个没有提供GUI版本:-)

我可能读了OSX论坛之类的东西,把.bashrc文件搞砸了


无论如何,谢谢你的回答

如果输入一个简单的命令,如$cmake./src/,是否会出现错误?你能写出完整的输出吗?谢谢你的回复。我也犯了同样的错误。我已经用$cmake./src/的完整输出更新了我的原始帖子。删除编译器配置后,出现相同错误是正常的。CMake使用缓存系统保存以前配置的信息。请删除CMakeCache.txt文件,然后重新运行
cmake./src
是否尝试使用较新版本的?感谢您的回复。我已经删除了缓存文件和CMakeFiles文件夹。我仍然会犯同样的错误。我还没有尝试过更新的版本,但是,我从Synaptic添加了CMake GUI,解决了这个问题。对于GUI版本:只需按Configure,然后按Generate按钮即可生成相应的Makefile。困扰我的是
-rpath
命令不正确,应该是
-Wl,-rpath
。这可能是测试CMakeLists文件中的一个bug,或者?