ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org
Ask Your Question
3

How to link with ros ARM libraries when cross compiling?

asked 2014-04-23 16:49:54 -0500

Hello,

I am cross compiling for the raspberry pi, on my Ubuntu 12.04 machine with ROS hydro. I am almost there, but am still unable to link to the proper (ARM native) ROS libraries when cross-compiling. I have a nodelet that is dependent on several ros libraries, including actionlib. I also have installed ROS on the raspberry pi natively (Setting up Hydro on RaspberryPi), and copied those libraries to the buildroot of my cross-compile on my Ubuntu machine (set to ~/rpi/rootfs). However, I cannot get Catkin and CMake to link to those ros libraries in the buildroot, instead it always tries to use the ones in /opt/ros/hydro.

The error is:

Linking CXX shared library... /opt/ros/hydro/lib/libactionlib.so: could not read symbols: File in wrong format collect2: ld returned 1 exit status

So, the linker is trying to link with the libactionlib.so in /opt/ros/hydro, when, it should link to the libactionlib.so in my buildroot folder.

I have setup a toolchain.raspi.cmake that looks like this:

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++-4.4)
set(CMAKE_FIND_ROOT_PATH $ENV{HOME}/rpi/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/sysroot $ENV{HOME}/rpi/rootfs $ENV{HOME}/rpi/rootfs/e2fsprogs-1.42.9 $ENV{HOME}/rpi/rootfs/usr $ENV{HOME}/rpi/rootfs/usr/lib $ENV{HOME}/rpi/rootfs/usr/include $ENV{HOME}/rpi/ros_catkin_ws/install_isolated)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

I have also tried running the following script, before running catkin_make, to no avail:

#!/usr/bin/env sh
export ROS_PACKAGE_PATH=/home/uav/catkin_ws:/home/uav/rpi/ros_catkin_ws/install_isolated
export ROS_ROOT=/home/uav/rpi/ros_catkin_ws/install_isolated
export LD_LIBRARY_PATH=/home/uav/rpi/ros_catkin_ws/install_isolated/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/home/uav/rpi/ros_catkin_ws/install_isolated/lib/pkgconfig:$PKG_CONFIG_PATH
export CMAKE_PREFIX_PATH=/home/uav/rpi/ros_catkin_ws/install_isolated:$CMAKE_PREFIX_PATH

Also, my catkin_make looks like this:

catkin_make_isolated --cmake-args -DCMAKE_TOOLCHAIN_FILE=/home/uav/rpi/toolchain.raspi.cmake -DBoost_INCLUDE_DIR=/home/uav/rpi/rootfs/usr/include

Is this an overlay issue? What do I need to do to get Catkin to link to the ROS libraries in the buildroot (for the raspi) and not in /opt/ros/hydro?

Another note, I got to this point because when I tried to run the nodelet on the raspi, it could not be loaded. Another post suggested that I explicitly link to the catkin_libraries in the CMakeLists.txt of the nodelet:

target_link_libraries(my_nodelet
   ${catkin_LIBRARIES}
 )

Thanks in advance!

edit retag flag offensive close merge delete

Comments

Update: I was able to temporarily get past this link error with this workaround, forcing the build to think the correct libraries are in hydro, but there must be a better way! cd /opt/ros/hydro sudo mv lib lib386 sudo ln -s ~/rpi/ros_catkin_ws/install_isolated/lib lib

ceverett gravatar imageceverett ( 2014-04-24 10:40:12 -0500 )edit

I think, it is not a real good solution, to make a softlink. For one test, it will be ok. But at a devel envirument, there should be a better solution!? BTW I have the same problem...

Patrick K gravatar imagePatrick K ( 2014-06-11 07:43:33 -0500 )edit

Any updates on this? I have the ARM toolchain installed on my desktop Ubuntu 16.04 and cross compilation works but linking does not work with the exact same error as above. Using an ARM-based main computer for ROS can't be that uncommon that noone has a working cross compilation solution, or is it?

ErikHells gravatar imageErikHells ( 2016-06-21 10:04:20 -0500 )edit

I'm stuck on the same problem.

Cerin gravatar imageCerin ( 2017-02-07 21:43:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
-1

answered 2017-08-22 08:31:21 -0500

oxoocoffee gravatar image

How did you set up cross compiling environment? I am on Ubuntu 16.04 x64 and want to install ROS arm64 packages so I can cross compile. I did try to add dpkg arm64 architecture and after updating installation fails with message of broken packages. Or did you tar /opt/ros on Arm and untar on your desktop to some folder as sysroot?

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

5 followers

Stats

Asked: 2014-04-23 16:49:54 -0500

Seen: 2,102 times

Last updated: Aug 22 '17