Ask Your Question
0

CMake fails with "No CMAKE_CXX_COMPILER could be found." (docker, melodic-ros-core)

asked 2021-08-19 14:43:06 -0600

130s gravatar image

updated 2021-08-20 05:39:02 -0600

gvdhoorn gravatar image

I have a workaround as below but installing a pkg with a package manager (e.g. apt) is supposed to be avoided by design of catkin (and many other packages packaged on ros.org) IMO, so I want to know a perm fix.

Issue

On a ROS melodic Docker image I just pulled, catkin build and catkin_make fails.

$ docker pull ros:melodic-ros-core
melodic-ros-core: Pulling from library/ros
Digest: sha256:9b03709d6c54ab97d50a1b99d3d00878071189aa2e7bf7faf3daac1c055bedc3
Status: Image is up to date for ros:melodic-ros-core
docker.io/library/ros:melodic-ros-core

$ DIR=/cws && mkdir -p $DIR/src && cd $DIR
$ apt update && apt install -y git python-catkin-tools
$ cd $DIR/src && git clone https://github.com/ros/std_msgs && cd $DIR
$ catkin init && catkin config --install
$ catkin build

:

Errors     << catkin_tools_prebuild:cmake /cws/logs/catkin_tools_prebuild/build.cmake.000.log                                                                                                                                                
CMake Error at /cws/build/catkin_tools_prebuild/CMakeLists.txt:2 (project):
  No CMAKE_C_COMPILER could be found.

  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 /cws/build/catkin_tools_prebuild/CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  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.

catkin_make

root@05c38516bda3:/cws# rm -fr build/ devel/ logs/ 
root@05c38516bda3:/cws# catkin_make
Base path: /cws
Source space: /cws/src
Build space: /cws/build
Devel space: /cws/devel
Install space: /cws/install
Creating symlink "/cws/src/CMakeLists.txt" pointing to "/opt/ros/melodic/share/catkin/cmake/toplevel.cmake"
####
#### Running command: "cmake /cws/src -DCATKIN_DEVEL_PREFIX=/cws/devel -DCMAKE_INSTALL_PREFIX=/cws/install -G Unix Makefiles" in "/cws/build"
####
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:6 (project):
  No CMAKE_C_COMPILER could be found.

  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:6 (project):
  No CMAKE_CXX_COMPILER could be found.

  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 "/cws/build/CMakeFiles/CMakeOutput.log".
See also "/cws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

Workaround worked

Same as https://answers.ros.org/question/2948..., installing build-essential apt pkg seems to bypass this.

Env

# apt-cache policy ros-melodic-catkin
ros-melodic-catkin:
  Installed: 0.7.29-1bionic.20201014.191449
  Candidate: 0.7.29-1bionic.20201014.191449
  Version table:
 *** 0.7.29-1bionic.20201014.191449 500
        500 http://packages.ros.org/ros/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

# apt-cache policy ...
(more)
edit retag flag offensive close merge delete

Comments

but installing a pkg with a package manager (e.g. apt) is supposed to be avoided by design of catkin

What do you mean exactly be this?

gvdhoorn gravatar image gvdhoorn  ( 2021-08-20 02:47:23 -0600 )edit

Answering to your question a bit differently though, what I wanted was to know if there's a way to avoid running aptto fill the requirement for Catkin. Then with your answer, and with the Melodic install wiki http://wiki.ros.org/melodic/Installat..., I realized build-essential is not even in Catkin's dependency tree. Problem solved.

130s gravatar image 130s  ( 2021-08-20 06:17:21 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-08-20 02:16:37 -0600

gvdhoorn gravatar image

updated 2021-08-20 03:04:28 -0600

For some time now, the "base" ROS Docker images have not shipped with any build-related packages.

This is on purpose, as it significantly reduces the size of the images, and those build dependencies are not used when you "just want to run ROS".

I'll try to find the announcement and link it here, but I thought I'd first post the answer.


Edit: from Announcement: trimmed ROS/Gazebo docker images released:

  • The ros-core images do not include the ROS bootstrapping / building tools anymore (removal of rosdep , rosinstall , colcon packages for ROS 2) these packages will now be part of the generic base image, aka ros:<ROS_DISTRO> or ros:<ROS_DISTRO>-ros-base
  • this means that images based on ros:<ROS_DISTRO>-ros-core images do not have compilers installed by default anymore. If you use those in CI you’ll need to make sure to install the building tools you need or use the ros-base (aka default) image. You can see the diff on the ros_core images here
  • the osrf/ros2:devel image including all the building and testing tools for ROS 2 can/should be used as a base for ROS 2 CI
  • there is currently no ROS 1 equivalent to the osrf/ros2:devel image. But we're happy to explore how to make this available if there is interest

You seem to use the ros:<ROS_DISTRO>-ros-core image, which is why CMake can't find the compiler.

Note btw:

catkin fails with "No CMAKE_CXX_COMPILER could be found."

CMake fails. Not Catkin.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-08-19 14:43:06 -0600

Seen: 346 times

Last updated: Aug 20