ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Compile ROS2 foxy binaries for other linux distro

asked 2021-11-09 06:50:02 -0600

xander-m2k gravatar image

I am currently working on a robot project where we are using Debian Buster for an industrial application. Debian is simply more reliable and future-proof than Ubuntu, that is the simple reason we are using Debian.

Since ROS2 Foxy is mainly supported on Ubuntu, I am having a hard time compiling binaries (.deb) for Debian. Building binaries for Ubuntu works fine with bloom-generate and dpkg-buildpackage, but this is not possible for the Debian distro because no Debian apt repositority for ROS2 Foxy exists.

Therefore I want to compile ROS2 Foxy myself for Debian Buster, but I am struggling really hard with it. Everything is dependend on each other, some things won't build, some things don't really work when installed, the ros/opt/foxy/ is not installed by any binary. In short, horrible experience trying it, but still trying. I don't know how I should tackle this.

I made a script my self which finds every folder with package.xml and than goes to that folder and executes bloom-generate and dpkg-buildpackage and than installing the package after. This works well, but after a while of repeatedly doing this, you start to bump into python packages not being sourced, because the lack of (I think)

I'm wondering if some kind of build script exist, which I can use for building ROS2 Foxy for Debian Buster, which also makes the ros-foxy-desktop or ros-foxy-ros-base package.

edit retag flag offensive close merge delete


Out of the problems you've faced, are you also getting rosdep unresolved dependency errors? For that specific issue, you can probably create a rosdep config file listing the dependencies (even custom packages) for the packages you're building.

aprotyas gravatar image aprotyas  ( 2021-11-09 10:36:38 -0600 )edit

@aprotyas I have passed that station a while ago... :)

xander-m2k gravatar image xander-m2k  ( 2021-11-09 10:38:31 -0600 )edit

Oops - best of luck regardless!

aprotyas gravatar image aprotyas  ( 2021-11-09 10:48:53 -0600 )edit

Perhaps you could take a look at meta-ros. Doing this yourself without the help of some system which takes care of build-ordering and dependency checking for you seems like it shouldn't be necessary.

Note: this is not "some kind of build script" which builds .debs for you. It's a different approach. But in an industrial context, building a complete rootfs may actually be a more viable approach.

gvdhoorn gravatar image gvdhoorn  ( 2021-11-09 12:18:11 -0600 )edit

@gvdhoorn, correct me if I'm wrong, but I think this repository is more focused on cross-compiling on Yocto (mostly arm64/aarch64), rather than focusing on compiling for another Linux distro. Also, I do actually need the ROS2 Foxy for Buster .debs for compiling my own ROS2 packages for Debian Buster, otherwise dpkg-buildpackage can't find the dependencies.

xander-m2k gravatar image xander-m2k  ( 2021-11-09 12:37:44 -0600 )edit

Yocto can certainly be used to build images for non-amd64 architectures, but it's also used for regular Intel/AMD/other-x86 platforms. There's nothing in there specific for cross-compilation.

I do actually need the ROS2 Foxy for Buster .debs for compiling my own ROS2 packages for Debian Buster, otherwise dpkg-buildpackage can't find the dependencies.

As I wrote, this is an entirely different approach. dpkg-buildpackage is not involved (or at least not in the way you're using it now).

gvdhoorn gravatar image gvdhoorn  ( 2021-11-09 12:40:06 -0600 )edit

@gvdhoorn, thanks for informing me. I will take a look at it and see if it's useful! Still needs the .debs though... For now, I will just build manually, which can be a pain, but I will get there. A big reason for the .debs is also to deploy it in a docker container for releasing my packages, which can just be easily updated and made with existing binaries.

xander-m2k gravatar image xander-m2k  ( 2021-11-09 12:47:50 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2021-11-09 17:41:08 -0600

m2-farzan gravatar image

Some suggestions:

1. Study Archlinux PKGBUILDS:

Archlinux lacks ROS2 binaries, so the Arch community created "PKGBUILDS" which are basically shell scripts that build ROS2 from scratch. They are pretty simple and you can easily figure out how they work. See this for foxy package itself and this for external dependencies.

2. Study Ubuntu packages:

This file contains the official packages and provides a list of their ROS and non-ROS dependencies (search for ros2-foxy-desktop for example). However, I couldn't find build instructions of the packages themselves. Studying their CI infrastructure might help but I'm not sure.

edit flag offensive delete link more


Nice answer.

osilva gravatar image osilva  ( 2021-11-09 18:29:29 -0600 )edit

The thing is that PKGBUILDS - or in fact, most of the suggestions provided to @xander-m2k so far - builds from source and that's it. He needs some way to create debians after-the-fact.

aprotyas gravatar image aprotyas  ( 2021-11-09 23:06:17 -0600 )edit

I found the ros_buildfarm repository ( and I think this might be able to do it. I'm going to put some time in it and see if I get it to do what I want it to do.

xander-m2k gravatar image xander-m2k  ( 2021-11-10 01:31:53 -0600 )edit

@m2-farzan Nice find, but this PKGBUILD script just uses colcon as well, nothing special here...
Also, I have just emailed the ros2-foxy-desktop package maintainer, if he could provide the source, so thanks for that.

The CI infrastructure comment you mention is basicly what I am trying to do on a local level, but it is not supported for Debian builds. In short, it's a real pain to set up all the different config files, which are not fully documented.

xander-m2k gravatar image xander-m2k  ( 2021-11-10 09:41:50 -0600 )edit

@xander-m2k Sorry, maybe I didn't fully understand the problem. Are you trying to avoid colcon for some reason or you're saying that you already use colcon but the problem is that you don't know which packages to clone before running colcon build? If it is the latter, did you notice the step in PKGBUILD in which it uses a file named ros2.repos to find all the required packages? For a quick glance, see that file online here.

m2-farzan gravatar image m2-farzan  ( 2021-11-10 12:17:44 -0600 )edit

I'm not trying to avoid colcon. colcon just does not provide the functionality of building binaries (.debs). It only compiles your project but does not package it. It would be perfect is colcon would have that kind of functionality.

xander-m2k gravatar image xander-m2k  ( 2021-11-10 12:20:15 -0600 )edit

Based on what that PKGBUILD does (package() function in the bottom), can't you just make a debian package that contains everything in the install directory that colcon build generates, and copies them to /opt/ros2/foxy directory of target system? Do you have technical problems with creating a debian package that copies some files to a directory or you can do that but you get errors?

m2-farzan gravatar image m2-farzan  ( 2021-11-10 12:31:28 -0600 )edit

Question Tools



Asked: 2021-11-09 06:50:02 -0600

Seen: 301 times

Last updated: Nov 09 '21