16

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

Ryan Lee
  • 361
  • 1
  • 3
  • 10

6 Answers6

4

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++
Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • Sorry, I realised theres a difference in the error. What should I export /usr/bin/c++ and /usr/bin/cc as? – Ryan Lee Jul 17 '17 at 14:06
  • 1
    You can leave the unset, I guess: `unset CC CXX`. But `/usr/bin/gcc` really should exist once you have installed the `build-essential` package. – Florian Weimer Jul 17 '17 at 14:11
  • I realised that when setting up distcc, I might have set symbolic links on g++ and gcc and c++ and cc. How do I go about checking and deleting them? – Ryan Lee Jul 17 '17 at 14:18
  • 2
    Uh-oh. `apt-get install --reinstall gcc` should reinstall the `gcc` package and correct the symbolic links. – Florian Weimer Jul 17 '17 at 14:21
  • That problem still persists. Have tried removing and resetting the exports. Would you know of any other tests to identify the root cause? – Ryan Lee Jul 17 '17 at 14:31
  • What's the output of `ls -l /usr/bin/*g{cc,++}*`? (The environment variables and the file system contents are completely separate matters.) – Florian Weimer Jul 17 '17 at 14:40
  • I did that command in home and in / Both replied no such file or directory – Ryan Lee Jul 17 '17 at 14:45
  • Then the compiler packages are not installed. I have no idea what you did to your system; it may be time to restore from backup or reinstall. – Florian Weimer Jul 17 '17 at 14:49
  • So I did them seperately `pi@raspberrypi:/ $ ls -l /usr/bin/gcc` `lrwxrwxrwx 1 root root 7 Mar 8 2015 /usr/bin/gcc -> gcc-4.9` `pi@raspberrypi:/ $ ls -l /usr/bin/g++` `lrwxrwxrwx 1 root root 7 Mar 8 2015 /usr/bin/g++ -> g++-4.9` Would it help? – Ryan Lee Jul 17 '17 at 14:53
  • When you type the `gcc` and `g++` commands, do they show `fatal error: no input files`? Then this part at least is set up correctly. – Florian Weimer Jul 17 '17 at 14:57
  • Yes they show `fatal error: no input files` Does it mean reinstall from backup? – Ryan Lee Jul 17 '17 at 14:58
  • No, it means that the compiler works so far. Please re-run the `cmake` command and post the results to the question. cmake also writes some `.txt` files explaining why specific tests have failed. You should look at this as well. – Florian Weimer Jul 17 '17 at 15:05
  • Did you find a solution? – quantumpotato Apr 06 '18 at 23:43
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++

Jamex Tzu
  • 21
  • 1
2

I had similar error while installing openCV 4.2.0 with cuda 10.2 on ubuntu 18.04. I rectified it by(change the gcc/g++ version accordingly)

sudo apt install gcc-6 g++-6
1

I have seen the same symptoms if you have build folders left behind from a build in a different environment (ie switching from local to a container, or between different container variants).

Ensure that you clean the generated build before retrying as it will cache locations to things it can no longer find.

Danny Staple
  • 7,101
  • 4
  • 43
  • 56
0

All of the above suggestions din't solve the problem for me at Ubuntu 18.04, It worked for me using:

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

After I already had:

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
GM1
  • 380
  • 3
  • 14
0

I gone through the problem when compiling opencv with cuda optimization. The compiler issued this message:

The CMAKE_C_COMPILER:
/usr/bin/gcc-6
is not a full path to an existing compiler tool.

see the output of cmake

The message actually is clear as it simply tells that it doesn't find gcc-6 at the indicated location which in this case is /usr/bin/gcc-6. To verified this I navigated into /usr/bin/ folder and ran the command ls gcc* to see all available gcc GNU C Compilers.

The image below shows what I got.

As one can see they were not gcc-6 available but instead gcc-9. Thus, I just had to indicate the relevant path -D CMAKE_C_COMPILER=/usr/bin/gcc-9 and every thing worked find. Note that In case there is any gcc GNU C complier present in /usr/bin/gcc-6 it mean that it no install and you will have to install it and compile opencv again.