catkin_make CMake cross-compile not finding libs: Librt, LibThreads

asked 2016-12-16 11:34:48 -0600

_ruben_ gravatar image

updated 2016-12-20 01:59:37 -0600

I need help configuring my setup to get a usable IDE working environment for ROS cross-compilation development. The setup is as following:

  • Raspberry Zero: compiled ROS kinetic successfully from source
  • 64Bit Ubuntu x86: able to cross-compile and remote debug Raspberry Zero (within Eclispe). Installed ROS via bin packages successfully

I want to crosscompile a ROS node (via make target in Eclipse CDT) on the Ubuntu machine, then remote debug ROS node on the Zero. I was able to generate an Eclipse project as well as building ROS node for x86. Via ssh I can build the ROS node on the zero, as well.

But it is impossible for me to figure out the root cause of what’s wrong with the environment configuration. I cannot convince catkin_make to build my node with the ARM compiler and environment.

Here's what I did:

First I created a toolchainfile /home/ruben/catkin_rpi_ws/rostoolchain.cmake to achieve cross-compile:

set(CMAKE_C_COMPILER /home/ruben/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER /home/ruben/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++)

set(CMAKE_FIND_ROOT_PATH /home/ruben/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/)
# Have to set this one to BOTH, to allow CMake to find rospack

Then I initialised environment

source /opt/ros/kinetic/setup.bash

I pulled a ROS node implementation from Git-Hub (I was able to build & exectue this on the Zero itself)

git clone src/ros-hc-sr04-node
Klone nach 'src/ros-hc-sr04-node' ...
remote: Counting objects: 54, done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 54 (delta 22), reused 54 (delta 22), pack-reused 0
Entpacke Objekte: 100% (54/54), Fertig.
Prüfe Konnektivität ... Fertig

Finally generated workspace

catkin_init_workspace src/
Creating symlink "/home/ruben/catkin_rpi_ws/src/CMakeLists.txt" pointing to "/opt/ros/kinetic/share/catkin/cmake/toplevel.cmake"

Then I give it a try to build it

catkin_make -DCMAKE_TOOLCHAIN_FILE=/home/ruben/catkin_rpi_ws/rostoolchain.cmake
Base path: /home/ruben/catkin_rpi_ws
Source space: /home/ruben/catkin_rpi_ws/src
Build space: /home/ruben/catkin_rpi_ws/build
Devel space: /home/ruben/catkin_rpi_ws/devel
Install space: /home/ruben/catkin_rpi_ws/install
#### Running command: "cmake /home/ruben/catkin_rpi_ws/src -DCMAKE_TOOLCHAIN_FILE=/home/ruben/catkin_rpi_ws/rostoolchain.cmake -DCATKIN_DEVEL_PREFIX=/home/ruben/catkin_rpi_ws/devel -DCMAKE_INSTALL_PREFIX=/home/ruben/catkin_rpi_ws/install -G Unix Makefiles" in "/home/ruben/catkin_rpi_ws/build"
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is GNU 4.8.3
-- Check for working C compiler: /home/ruben/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /home/ruben/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/ruben/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /home/ruben/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using CATKIN_DEVEL_PREFIX: /home/ruben/catkin_rpi_ws ...
edit retag flag offensive close merge delete


Not to discourage you, but I think you have an issue people generally try to avoid by either compiling on target, or by building entire root fs using OpenEmbedded or similar tools.

I can't help you I'm afraid, other than saying that I'd try to first get things working without Eclipse ..

gvdhoorn gravatar image gvdhoorn  ( 2016-12-20 05:17:53 -0600 )edit

..: your last update shows that that also doesn't work (yet).

And finally (but I think you already have that clear): catkin is basically CMake. It does use some trickery here and there, but it should leave most things alone.

Have you tried catkin_tools?

gvdhoorn gravatar image gvdhoorn  ( 2016-12-20 05:22:27 -0600 )edit

I'll have a look with Yocto and OpenEmbedded. In parallel I try to get at least the crosscompile of that node done. It turns out that I need to apply changes in nodes CMakeLists, which I guess is way far from reusability, e.g. link_directories(...), include_directories(...).

_ruben_ gravatar image _ruben_  ( 2016-12-21 00:54:14 -0600 )edit

I'm not suggesting that you should just move to Yocto & friends per se. I just wanted to give you a possible rationale for why you (can) find little information on this: cross-compilation can be difficult to get right, so users typically tend to avoid it and use something 'easier'.

gvdhoorn gravatar image gvdhoorn  ( 2016-12-21 02:12:51 -0600 )edit

Having to change paths manually is definitely not something that should be needed. For a typical cross-compilation setup you'd only want to change the sysroot and that should be it. I've seen people use Docker images for this.

gvdhoorn gravatar image gvdhoorn  ( 2016-12-21 02:14:36 -0600 )edit