在一台新搭建的服务器上执行cmake的时候,报了如下错误:

$ cmake ./
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 4.4.
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake: (message):
The C compiler "/usr/bin/cc" is not able to compile a simple test program. It fails with the following output: ...

查看下gcc与g++的版本:

$ gcc --version
gcc (GCC) 5.1.
Copyright (C) Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ --version
g++ (GCC) 5.1.
Copyright (C) Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

发现都是5.1.0,那为何会有这行“The CXX compiler identification is GNU 4.4.7”报错呢?

查看当前目录下的CMakeCache.txt

发现如下两行配置:

//CXX compiler.
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ //C compiler.
CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc

执行 /usr/bin/c++ --version 和 /usr/bin/cc --version,发现输出的版本号仍然是5.1.0,这就有点莫名其妙了。

google搜索出了一个github issue:https://github.com/Kingsford-Group/genesum/issues/2,在里面找到了解决方案:

cmake -DCMAKE_CXX_COMPILER=$(which g++) -DCMAKE_C_COMPILER=$(which gcc) ./

执行之后果然可以了,并且重新打开了CMakeCache.txt之后发现,编译器的两个选项改变了:

//CXX compiler.
CMAKE_CXX_COMPILER:FILEPATH=/usr/local/bin/g++ //C compiler.
CMAKE_C_COMPILER:FILEPATH=/usr/local/bin/gcc

这两个路径与命令 which gcc 和 which g++的输出一致。

猜测手动改CMakeCache.txt 的这两项应该也可以解决问题,比较困惑的就是,为何运行/usr/bin/c++ --version得到的版本号仍然是5.1.0?

这个疑惑要留待以后来解决了。

cmake的一个编译报错的更多相关文章

  1. IntelliJ Idea中一个编译报错引发的

    package verify; public class Verifier { private String name; public Verifier() { this.name = getClas ...

  2. CentOS7安装mysql8.0编译报错集合

    以下都是我安装mysql8.0遇到的一些报错和解决方法 1.does not appear to contain CMakeLists.txt. 原因:mysql下载的源码包不对 解决方法:下载正确的 ...

  3. cordova编译报错:Execution failed for task ':processDebugResources'

    cordova编译报错:Execution failed for task ':processDebugResources' 引发这个错误的最扩祸首就是一个中文命名的文件,不知道什么时候加入的,我写了 ...

  4. jenkis编译报错:需要class,interface或enum

    现象: 1.jenkis编译报错:需要class,interface或enum 2.使用ant进行编译ok. 解决方法: 1. Jenkis重新编译一个以前成功的svn版本,直至编译成功. 2.Jen ...

  5. 对arm指令集的疑惑,静态库运行,编译报错等问题

    转载自http://www.jianshu.com/p/4a70aa03a4ea?utm_campaign=hugo&utm_medium=reader_share&utm_conte ...

  6. IntelliJ Idea编译报错:javacTask: 源发行版 1.7 需要目标发行版 1.7

    1.项目编译时,IntelliJ Idea编译报错:javacTask: 源发行版 1.7 需要目标发行版 1.7很显然是jdk版本冲突,于是查阅资料,作如下修改:File-->Other Se ...

  7. caffe编译报错解决

    添加ssd中的一些层之后,编译报错: ../lib/libcaffe.so.1.0.0-rc5:对‘boost::match_results<__gnu_cxx::__normal_iterat ...

  8. Linux QtCreator 编译报错:No rule to make target '.../***' needed by '***.o'.stop

    Linux QtCreator 编译报错:No rule to make target 'mainwindow.cpp'  needed by  'mainwindow.o'.stop [1]解决方案 ...

  9. win7 X64 使用VS2008 ->编译报错LINK : fatal error LNK1000: Internal error during Incr的解决

    编译报错LINK : fatal error LNK1000: Internal error during Incr的解决 Win7 旗舰版 Microsoft Visual Studio 2008 ...

随机推荐

  1. poj3189二分图多重匹配

    题意:有一些牛和牛棚(有容量),每头牛对牛棚有喜好程度,要求每头牛都有一个棚子的情况下,找最小的喜好程度之差 题解:题意是真的恶心,wa了好久才发现没读懂,一直以为输入 的是排名,其实是牛棚标号,从1 ...

  2. SQL Server 删除默认值

    alter table st_FuelConvertPatternSetting alter column tank_max_size decimal(5,2) not null declare @c ...

  3. 28 python 并发编程之多进程

    一 multiprocessing模块介绍 python中的多线程无法利用多核优势,如果想要充分地使用多核CPU的资源(os.cpu_count()查看),在python中大部分情况需要使用多进程.P ...

  4. LeetCode OJ:Minimum Size Subarray Sum(最小子数组的和)

    Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

  5. 源码编译安装mysql5.6

    1.download the source package and unzip to the destination dir http://mirror.switch.ch/mirror/mysql/ ...

  6. 马拉车——模版+KMP——模版

    void Manacher(){ ;t[i];++i,len+=){ s[i<<]='#'; |]=t[i]-'A'+'a'; |]=t[i]; } s[len++]='#'; ,pos= ...

  7. RESTful 组件

    1. CBV FBV: url("index/",index) # index(request) url("index/(\d+)",index) # inde ...

  8. Ajax做无刷新三级联动

    1.引入JS and Jquery包 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  9. ecmall中的分页问题

    <ecmall>Ecmall系统自带的分页功能 在Ecmall的二次开发中,分页是必不可少的.这个系统已经自带了分页功能,下面来看看如何使用这个分页. 下面是一个自定义的类,用于查看订单的 ...

  10. eShopOnWeb

    eShopOnWeb https://www.cnblogs.com/sheng-jie/p/9616675.html 构建现代Web应用 1.引言 eShopOnWeb是基于ASP.NET Core ...