Cross compiling ROS for ARM fails to link roscpp
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?
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.
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?
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.