cmake的一个编译报错

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

$ cmake ./
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 4.4.7
-- 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:61 (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.0
Copyright (C) 2015 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.0
Copyright (C) 2015 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?

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

原文地址:https://www.cnblogs.com/qiumingcheng/p/11146051.html

时间: 2024-07-30 02:13:57

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

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

package verify; public class Verifier { private String name; public Verifier() { this.name = getClass().getName();//getClass()在ItelliJ idea中会报错: } public static void main(String[] args) { Verifier verifier = new Verifier(); System.out.println("可以正常编译

升级redis3.2.7编译报错“ undefined reference to `clock_gettime'”

由于redis有个紧急的安全漏洞更新所以我升级线上的redis-cluster的版本.编译时报了一个错:" redis-3.2.7/deps/jemalloc/src/nstime.c:120: undefined reference to `clock_gettime' collect2: ld returned 1 exit status make[1]: *** [redis-server] Error 1 make[1]: Leaving directory `redis-3.2.7/s

webpack编译报错:Module not found: Error: Cannot resolve 'file' or 'directory' ./../../node_modules..

在同事的mac电脑上,可以正常编译,拿到我这边就出错了(⊙﹏⊙) 好像是webpack在window下的一个bug,需要让 webpack 和你的项目保持在一个盘符下,参考. 解决方法: 修改config.js配置文件,在所有目录前加上path.join,参考1,参考2. webpack编译报错:Module not found: Error: Cannot resolve 'file' or 'directory' ./../../node_modules..

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

转载自http://www.jianshu.com/p/4a70aa03a4ea?utm_campaign=hugo&utm_medium=reader_share&utm_content=note&utm_source=qq 对arm指令集的疑惑,静态库运行的问题,翻看了很多资料,整理如下: 1:blog.csdn.net/lizhongfu2013/article/details/42387311 下面内容转发自上述链接:iOS开发-制作同时支持armv7,armv7s,arm

libvirt编译报错

virsh # list --all错误:连接到管理程序失败错误:无效的连接错误:将插槽连接到 '/usr/local/var/run/libvirt/libvirt-sock' 失败: 没有那个文件或目录 建一个链接. ln -s /var/run/libvirt/libvirt-sock /usr/local/var/run/libvirt/libvirt-sock libvirt编译报错

Android Studio导入Fresco项目编译报错unable to expand TAR 'imagepipeline\build\downloads\libjpeg-turbo-1.3.1.tar.gz'解决

把github上的一个Fresco的demo源码clone到本地(附clone地址:https://github.com/facebook/fresco.git),导入这个fresco项目编译报了如题所示的错.经过网上搜索解决方案,只找到了下面链接给的解决方案: unable to expand TAR 'imagepipeline\build\downloads\libjpeg-turbo-1.3.1.tar.gz解决 按照上面链接给的方法试了一下,结果无法解决.还是报同样的错误.然后我试着去

WF编译报错

最近在研究WF的时候,遇到了一个未知的错误,错误信息时这样的 错误 102 扩展“Microsoft.Activities.Build.Validation.ValidationBuildExtension”引发了“System.Xaml.XamlObjectWriterException”类型的异常:“对类型“Founder.Framework.Workflow.WF.Data.TaskActivity”的构造函数执行符合指定的绑定约束的调用时引发了异常.”. Founder.Framewor

启动项目,编译报错:Consider defining a bean of type 'XXX' in your configuration.

在controller层注入ConfigBean,编译器报错: 一开是以为是intellij idea 的告警级别设定的问题,就没有在意,继续启动项目,结果控制台报错:Consider defining a bean of type 'XXX' in your configuration. 错误信息显示找不到这个Bean类. 但是我明明写了啊. 后来经过一番查找,大概有了如下理解:主要问题出在@SpringBootApplication 这个注解上. 点进这个注解,可以看到,此注解功能大概由下面

android4.4 编译报错,和llvm 有关的

问题描述 最近想看一下android4.4 的source ,但是在编译的过程中遇到了下面的问题,各位大哥帮忙看一下,我实在是搞不定了,网上介绍的关于4.0 的类似的错误修改方法在4.4 上无效,其实错误也不是一样的. 4.0 的错误修改方法: $vi external/llvm/llvm-host-build.mk + LOCAL_LDLIBS := -lpthread -ldl 下面的是4.4 编译报错信息 external/llvm/lib/Transforms/Vectorize/BBV