BalenaOS catkin_make / cmake failing under cross-build

First off thanks for a great OS and community.
I’m running into some problems that I think is related to the cross-build feature.
I will describe my findings in the hopes that someone is able to spot the problem or help guide me to a solution.

I’m building two different docker images. One with just a ROS installation and then one building on top of that with my own dependencies and ROS nodes.

If i build this without the cross-build feature it works without a problem. But with cross-build it will fail on the line

RUN . /opt/ros/noetic/ && catkin_make

with this error

  find_package(catkin) failed.  catkin was neither found in the workspace nor
  in the CMAKE_PREFIX_PATH.  One reason may be that no ROS was
  sourced before.

I have made sure that the right setup file is sourced with some console prints. Also tried adding catkin as a ROS package and feeding the catkin_make the path.

I have also build the container without trying to run catkin_make and it builds fine.
If i then boot up the container and enter it to run the two same commands it builds the workspace without a problem and all works. Sadly this is not a lasting solution.

Really hope someone have worked with this and found a solution! The two dockerfiles are linked below.


The two dockerfiles I’m working with:

Base ROS image following the setup from ROS just with Balena cross-build feature.

FROM balenalib/raspberrypi3-ubuntu:focal

RUN ["cross-build-start"]

RUN echo 'Etc/UTC' > /etc/timezone && \
    ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
    apt-get update && \
    apt-get install -q -y --no-install-recommends tzdata && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -q -y --no-install-recommends \
    dirmngr \
    gnupg2 \
    && rm -rf /var/lib/apt/lists/*

RUN apt-key adv --keyserver hkp:// --recv-keys C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

RUN echo "deb focal main" > /etc/apt/sources.list.d/ros1-latest.list



RUN apt-get update && apt-get install -y --no-install-recommends \
    ros-noetic-ros-core=1.5.0-1* \
    && rm -rf /var/lib/apt/lists/*

RUN ["cross-build-end"]

CMD ["bash"]

My dockerfile building on top of the ROS base image.

FROM docker-image-registry/ros_docker_image_base

RUN ["cross-build-start"]

RUN apt-get update && apt-get install -y \
    libmysqlcppconn-dev \
    python3-pip \
    python3-wstool \
    python3-catkin-tools \
    python3-catkin-lint \
    python3-osrf-pycommon \
    automake \
    autoconf \
    libtool \
    libmodbus-dev \
    libmodbus5 \
    && rm -rf /var/lib/apt/lists/*

COPY libs/WiringPi /opt/ros/noetic/lib/WiringPi

WORKDIR /opt/ros/noetic/lib/WiringPi

RUN ./build


RUN rosdep init && rosdep update

COPY ros_ws/src /ws/src

RUN . /opt/ros/noetic/ && \
    apt-get update && rosdep install -y \
      --from-paths /ws/src \
      --ignore-src \
    && rm -rf /var/lib/apt/lists/*

RUN . /opt/ros/noetic/ && catkin_make
COPY rosmain.launch / \ /


RUN ["cross-build-end"] 


CMD ["roslaunch","/rosmain.launch"]

Hey there, first off welcome to the forums and thank you for the kind words!

I tried to reproduce this locally but without some of the source code I wasn’t able to get very far. Do you have a snippet of the files from libs/WiringPi and ros_ws/src that we could try to reproduce with? Even just some sample code so we can get past the initial commands. I tried to skip straight to catkin_make but it expects some src files.

Are you pushing these images to the balenaCloud platform or using them elsewhere with docker? If you’re pushing the 2nd image to a balenaCloud app anyway you could try using our ARM builders without the cross-build commands. With the balena CLI it’s just a matter of balena push <app>.

Offhand I can’t think of why the behaviour would be different with cross-build enabled but I haven’t used ROS personally. We would still like to figure out why the cross-build command doesn’t work though, so any assistance is appreciated!

1 Like

Thanks for getting back to me.

We’re building via. BitBucket pipelines doing development, haven’t made the move to BalenaCloud yet, it’s one of the things i’m testing for.

I have made a repo where i can reproduce the error and hoping it can get you on track.

The command giving me problems are out commented in the Dockerfile.

Building the container, moving it to the Pi and running the command myself is working and ROS is building fine that way.

Thank you so much for sharing those sources, that makes troubleshooting so much easier!

The problem is using qemu (any version) to emulate arm32 seems to trip up the cmake compiler_id_detection. I reproduced it with the latest qemu static outside of the build process.

This issue seems to have been raised with cmake already, and the fix is in cmake 3.18.

I added a code snippet to build cmake 3.20 from source, but it takes a very long time (especially with emulation) but you can give it a try by adding this snippet anytime before catkin_make.

WORKDIR /opt/cmake

RUN curl -L -O && \
    tar xvf cmake-3.20.0-rc3.tar.gz --strip-components=1 && \
    ./bootstrap && make -j"$(nproc)" && make install


Mine’s still building… but hopefully this helps!

1 Like

Hey Klutchell

Sorry for the delayed respond got sent away on business.

Thanks a lot for the fast answer and support. Will try it out later next week!