Ask Your Question
3

Cross compiling ROS for ARM fails to link roscpp

asked 2015-10-15 13:31:17 -0500

I.T gravatar image

updated 2015-10-16 02:49:01 -0500

gvdhoorn gravatar image

Hi,

I'm posting this as a follow up to a previous question I asked.

Since asking that question I have changed my embedded board to an Odroid XU4 running Ubuntu 15.04. I'm trying to cross compile ROS-Jade (Bare bones) for the Odroid. My computer also runs Ubuntu 15.04. What I have done so far:

1) Installed arm-linux-gnueabihf-gcc cross toolchain.

2) Created a sysroot for the board in my computer, in which I have folders bin, lib and arm-linux-gnueabihf copied from the Odroid.

3) Created a cmake toolchain file, odroid.cmake:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)

SET(catkin_DIR $ENV{HOME}/ros-arm-jade/ros_install_ws/devel_isolated/catkin/share/catkin/cmake)
SET(gencpp_DIR $ENV{HOME}/ros-arm-jade/ros_install_ws/devel_isolated/gencpp/share/gencpp/cmake)
SET(geneus_DIR $ENV{HOME}/ros-arm-jade/ros_install_ws/devel_isolated/geneus/share/geneus/cmake)
SET(genlisp_DIR $ENV{HOME}/ros-arm-jade/ros_install_ws/devel_isolated/genlisp/share/genlisp/cmake)

set(CMAKE_LIBRARY_PATH
  $ENV{HOME}/odroid/rootfs/usr/lib
  $ENV{HOME}/odroid/rootfs/usr/lib/arm-linux-gnueabihf)

set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH}
  $ENV{HOME}/odroid/rootfs/usr/lib
  $ENV{HOME}/odroid/rootfs/usr/lib/arm-linux-gnueabihf)

SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/odroid/rootfs)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)

4) Followed the install from source instructions for Jade, where I'm stuck at the compile step

./src/catkin/bin/catkin_make_isolated -DCMAKE_TOOLCHAIN_FILE=$HOME/odroid/odroid.cmake -DCMAKE_BUILD_TYPE=Release

The error I get looks like the following

Linking CXX shared library /home/it/ros-arm-jade/ros_install_ws/devel_isolated/roscpp/lib/libroscpp.so
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld: /home/it/odroid/rootfs/usr/lib/arm-linux-gnueabihf/libm.a(w_fmod.o): relocation R_ARM_THM_MOVW_ABS_NC against `_LIB_VERSION' can not be used when making a shared object; recompile with -fPIC
/home/it/odroid/rootfs/usr/lib/arm-linux-gnueabihf/libm.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

I got a similar error (recompile with -fPIC) for an earlier package, complaining about linking to libzl2. I solved that issue by downloading the libzl2 sources and actually compiling with -fPIC, then replacing the libzl2 library in my sysroot with the newly compiled one. But this time it complains about libm, which I would not like to recompile with -fPIC.

Googling about this I found somewhere that the linking should be done to the .so file instead of the .a file. In my sysroot I have both ~/odroid/rootfs/lib/arm-linux-gnueabihf/libm.a and lib/arm-linux-gnueabihf/libm.so.6. I tried creating a symlink lib/arm-linux-gnueabihf/libm.so pointing to libm.so.6, but that still yields the same error as above.

Any ideas?

edit retag flag offensive close merge delete

Comments

No one..? I find it fascinating the ROBOT Operating System seems so hard to cross compile for an embedded target, like, you know, an actual robot.

I.T gravatar imageI.T ( 2015-10-25 11:25:46 -0500 )edit
1

It can certainly be done, seeing as the new buildfarm is building ARMhf binaries already. Perhaps @tfoote or @Dirk Thomas can shed some light on this?

gvdhoorn gravatar imagegvdhoorn ( 2015-10-26 10:03:56 -0500 )edit

The NDK stuff is cross compiled for Android using docker: http://wiki.ros.org/android_ndk That might be a starting place. I think the build farm uses QEMU in conjunction with docker to build the ARM debians. In both cases everything compiles and runs, so I'm not sure about the OP's issue.

William gravatar imageWilliam ( 2015-10-26 13:54:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-26 15:58:49 -0500

tfoote gravatar image

If you're having trouble with linking against parts of the the core cross compile toolchain I suspect that you are missing some potential flags necessary in your cross compile toolchain. Your toolchain file is very short. The one that I've seen used the most is the android toolchain file. A quick search finds a copy here: https://github.com/taka-no-me/android... which does a lot more.

Cross-compiling is not a common task and will not work out of the box since it needs to be targeted correctly requiring understanding and learning about the process.

Many people do use ROS on odroid. However instead of cross compiling they typically build on the device or an emulated device. You can install binary packages from apt: http://wiki.ros.org/jade/Installation... for Jade as well as Indigo and compile your package on top of those binaries.

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

1 follower

Stats

Asked: 2015-10-15 13:31:17 -0500

Seen: 1,610 times

Last updated: Oct 26 '15