CMake fails with "No CMAKE_CXX_COMPILER could be found." (docker, melodic-ros-core)
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 ...
What do you mean exactly be this?
Answering to your question a bit differently though, what I wanted was to know if there's a way to avoid running
apt
to fill the requirement for Catkin. Then with your answer, and with the Melodic install wiki http://wiki.ros.org/melodic/Installat..., I realizedbuild-essential
is not even in Catkin's dependency tree. Problem solved.