【已解决】centos下CMAKE编译报gcc版本冲突

CMake Error at CMakeLists.txt:39 (project):
  The CMAKE_C_COMPILER:

    /usr/bin/c++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:39 (project):
  The CMAKE_CXX_COMPILER:

    /usr/bin/c++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:39 (project):
  The CMAKE_ASM_COMPILER:

    /usr/bin/cc

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "ASM" or the CMake cache entry CMAKE_ASM_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

解决方法:

方法1、在gcc安装之前先卸载历史版本,避免2个版本并存的问题

#先卸载

$yum remove gcc -y

$yum erase gcc

#安装

$ sudo yum install centos-release-scl -y

$ sudo yum install devtoolset-7-gcc* -y

$ scl enable devtoolset-7 bash    #Run for each time or add this line into the ~/.bashrc file

$ which gcc

$ gcc --version

方法2、参考:(49条消息) [CentOS]如何解决gcc版本冲突?_u012973744的专栏-CSDN博客

######1、查找系统中的gcc文件,并逐个目录检查相关版本 gcc --version,找到低版本目录,并替换低版本的执行文件路径、建立新版本的软连接

$find / -name gcc #
/opt/rh/devtoolset-7/root/usr/libexec/gcc
/opt/rh/devtoolset-7/root/usr/lib/gcc
/opt/rh/devtoolset-7/root/usr/bin/gcc  #7.3.1-5

/usr/libexec/gcc
/usr/lib/gcc
/usr/bin/gcc #4.8.5

解决办法:
$mv /usr/bin/gcc /usr/bin/gcc4.8.5
$ln -s /opt/rh/devtoolset-7/root/usr/bin/gcc /usr/bin/gcc
 

同理:还需要处理c++、g++、cc的

结果:按照这种方式处理后还有些问题,后来改成了方式1来处理,基本解决了,不再报错

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值