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

【已解决】centos下CMAKE编译报gcc版本冲突_第1张图片

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来处理,基本解决了,不再报错

你可能感兴趣的:(AI测试,centos,linux,运维)