CMAKE_C_COMPILER is not a full path to an existing compiler tool

风流意气都作罢 提交于 2019-12-19 18:56:35

问题


I recently explored distcc and couldn't make it work. So I

sudo apt-get remove distcc

After that, I get the error

==> Processing catkin package: 'gencpp'
==> Building with env: '/opt/ros/kinetic/env.sh'
Makefile exists, skipping explicit cmake invocation...
==> make cmake_check_build_system in '/home/pi/ros_catkin_ws/build_isolated/gencpp'
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_C_COMPILER:

    /usr/local/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 "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:2 (project):
  The CMAKE_CXX_COMPILER:

    /usr/local/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.

-- Configuring incomplete, errors occurred!
See also "/home/pi/ros_catkin_ws/build_isolated/gencpp/CMakeFiles/CMakeOutput.log".
See also "/home/pi/ros_catkin_ws/build_isolated/gencpp/CMakeFiles/CMakeError.log".
Makefile:304: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
<== Failed to process package 'gencpp': 
  Command '['/opt/ros/kinetic/env.sh', 'make', 'cmake_check_build_system']' returned non-zero exit status 2

Reproduce this error by running:
==> cd /home/pi/ros_catkin_ws/build_isolated/gencpp && /opt/ros/kinetic/env.sh make cmake_check_build_system

Command failed, exiting.

I have done

sudo apt-get install build_essential
sudo apt-get -f install
sudo apt-get update
sudo apt-get upgrade
export CC=/usr/local/bin/gcc
export CXX=/usr/local/bin/g++

but still get the same error.

How could I resolve this error? I have tried resetting the symbolic links and removing the exports


回答1:


I think you should unset CC and CXX, or at least use the system compilers, like this (drop the /local):

export CC=/usr/bin/gcc
export CXX=/usr/bin/g++



回答2:


you need to check where your gcc and g++ located, and make a soft link because i use CentOS

yum -y install centos-release-scl
yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils

to install the gcc so I need to do the following to avoid the same error as you

sudo ln -s /opt/rh/devtoolset-8/root/usr/bin/gcc /usr/bin/cc
sudo ln -s /opt/rh/devtoolset-8/root/usr/bin/g++ /usr/bin/c++



来源:https://stackoverflow.com/questions/45140273/cmake-c-compiler-is-not-a-full-path-to-an-existing-compiler-tool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!