CMAKE_C_COMPILER不是现有编译器工具的完整路径

时间:2017-07-17 09:17:08

标签: gcc makefile g++ distcc

我最近探索了distcc并且无法使其发挥作用。所以我

sudo apt-get remove distcc

之后,我收到错误

==> 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.

我已经完成了

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++

但仍然得到同样的错误。

我该如何解决此错误?我已经尝试重置符号链接并删除导出

4 个答案:

答案 0 :(得分:1)

您需要检查gcc和g ++的位置,并进行软链接 因为我使用CentOS

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

安装gcc 所以我需要执行以下操作以避免与您相同的错误

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++

答案 1 :(得分:1)

在ubuntu 18.04上使用cuda 10.2安装openCV 4.2.0时遇到类似的错误。我通过(相应更改gcc / g ++版本)进行了纠正

sudo apt install gcc-6 g++-6

答案 2 :(得分:0)

我认为您应该取消设置CCCXX,或至少使用系统编译器,如下所示(删除/local):

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

答案 3 :(得分:0)

以上所有建议都无法在Ubuntu 18.04上为我解决问题,它对我有效,使用:

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-7 70

在我吃完之后:

sudo update-alternatives --install /usr/bin/c++ g++ /usr/bin/g++-7 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70