Error Cross-compile ROS2 for ARM (bbb)

659 views
Skip to first unread message

carlos....@gmail.com

unread,
Jul 5, 2016, 7:05:38 PM7/5/16
to ROS SIG NG ROS
I am a newbie with ROS2 and cross compiling for ARM. I'm trying to cross compile ROS2 for a bbb (beagle bone black) an ARM7 single board computer, I'm running the cross-compilation in a desktop PC with Ubuntu 14.04 x86 (I know I need to upgrade).

Im trying to compile the ROS2 with this command:

src/ament/ament_tools/scripts/ament.py build --cmake-args -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabi-g++ -DCMAKE_LINKER=/usr/bin/arm-linux-gnueabi-ld -DBOOST_LIBRARYDIR=~/boost_1_61_0/stage/lib

All the things appear to be OK but in one moment i get this message:


Linking CXX executable DeadlineQoSExample
/home/cfe/ros2_ws/build/fastrtps/src/cpp/libfastrtps.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[5]: *** [DeadlineQoSExample] Error 1
make[4]: *** [CMakeFiles/DeadlineQoSExample.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [examples/DeadlineQoSExample-prefix/src/DeadlineQoSExample-stamp/DeadlineQoSExample-build] Error 2
make[1]: *** [examples/CMakeFiles/DeadlineQoSExample.dir/all] Error 2
make: *** [all] Error 2

<== Command '. /home/cfe/ros2_ws/build/fastrtps/cmake__build.sh && /usr/bin/make -j2 -l2' failed with exit code '2'

I hope you could help me. Thank you in advance.

Morgan Quigley

unread,
Jul 6, 2016, 4:36:23 PM7/6/16
to ros-sig...@googlegroups.com
Hi Carlos,

Thanks for writing and sharing your experience.

I'm not sure there is readily-accessible documentation providing step-by-step instructions for this at the moment, and I could be wrong, but in general I think you'll have an easier time using native compilers rather than cross-compiling. I know that's hard to do on a low-power device such as the BBB, but you could try running QEMU or other host-side emulation to virtualize a "larger" ARM machine and then copy the binaries over to the real hardware.

I suspect what's happening is that some of the ROS2 build is correctly cross-compiling, but other parts (for example, FastRTPS) are using the native compiler, so it's trying to link ARM and x86 code, which is impossible.

The ideal solution is to descend into the packages that aren't correctly cross-compiling and fix the root cause, but in the interim, I think you might make faster progress by building in a virtualized ARM environment.

Best regards,
Morgan

--
You received this message because you are subscribed to the Google Groups "ROS SIG NG ROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-ng-ro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

carlos....@gmail.com

unread,
Jul 7, 2016, 12:44:20 PM7/7/16
to ROS SIG NG ROS
Thank you Morgan,

I will follow your advice. 
In other hand, are there plans for to release a Python "service" ? I only see the talker and listener example.

Best Regards.
Carlos Armenta 

Morgan Quigley

unread,
Jul 7, 2016, 12:51:59 PM7/7/16
to ros-sig...@googlegroups.com
Hi Carlos,

Yes, there are plans to produce Python services, as in rospy. The ideal path to get there is to push services into rcl, which becomes the "ancestor" client library to rclcpp and rclpy. More roadmap items are shown here:

https://github.com/ros2/ros2/wiki/Roadmap

As always, contributions are certainly welcome!

Best regards,
Morgan

Esteve Fernandez

unread,
Jul 8, 2016, 10:30:30 AM7/8/16
to ROS SIG NG ROS
Hi,

I've cross-compiled ROS2, but for the Raspberry Pi, though. In any case, you also need to pass --ament-cmake-args (with the same CMake arguments) to ament, just to make sure that Ament CMake packages are cross-compiled as well. Also, you can disable Fast-RTPS' examples by passing -DCOMPILE_EXAMPLES=OFF to the --(ament-)cmake-args option.

For cross-compiling for the Raspberry Pi, I used the cross-compiler from:

https://github.com/raspberrypi/tools

To have all the dependencies, basically what I did was to fetch the Raspbian ARM image and extract the root filesystem. I then installed all the ROS2 dependencies via QEmu and apt-get, and then used the Raspbian root filesystem to feed the dependencies into CMake. Here's the CMake toolchain I wrote, hope it helps, it's a bit brittle, I'm sure there's a lot of stuff that can be refactored and deduplicated, but so far it works for me:

https://gist.github.com/esteve/a2955dc681c46ac9f8a9222adb239284

Please note that I built ROS2 in isolation, so you'll need to adapt the paths in https://gist.github.com/esteve/a2955dc681c46ac9f8a9222adb239284#file-raspberrypi-toolchain-cmake-L31-L54

Let me know if I can help somehow and don't hesitate to ask :-)

Cheers.

Aptschihu Buktu

unread,
Aug 23, 2016, 8:02:07 AM8/23/16
to ROS SIG NG ROS
Hello,

I found out that `pthread`-lib is missing for the linker. I put this in a patch file:

ros2_ws$ diff -ruN src srcn
diff
-ruN src/eProsima/Fast-RTPS/examples/C++/DeadlineQoSExample/CMakeLists.txt srcn/eProsima/Fast-RTPS/examples/C++/DeadlineQoSExample/CMakeLists.txt
--- src/eProsima/Fast-RTPS/examples/C++/DeadlineQoSExample/CMakeLists.txt    2016-08-23 13:19:14.863750211 +0200
+++ srcn/eProsima/Fast-RTPS/examples/C++/DeadlineQoSExample/CMakeLists.txt    2016-08-23 13:26:45.647729199 +0200
@@ -37,7 +37,7 @@
 
 add_executable
(DeadlineQoSExample ${DEADLINEQOS_EXAMPLE_SOURCES})
 target_include_directories
(DeadlineQoSExample PRIVATE ${Boost_INCLUDE_DIR})
-target_link_libraries(DeadlineQoSExample fastrtps fastcdr ${Boost_LIBRARIES})
+target_link_libraries(DeadlineQoSExample fastrtps fastcdr ${Boost_LIBRARIES} pthread)
 install
(TARGETS DeadlineQoSExample
     RUNTIME DESTINATION examples
/C++/DeadlineQoSExample/${BIN_INSTALL_DIR}
     
)

You can youse this patch as follows:

pi@raspberrypi:~/ros2_ws $ patch -p0 < src.patch
patching file src
/eProsima/Fast-RTPS/examples/C++/DeadlineQoSExample/CMakeLists.txt
src.patch

Brian Gerkey

unread,
Aug 23, 2016, 1:12:15 PM8/23/16
to ros-sig...@googlegroups.com
Thanks for the report. As it happens, I ran into the same problem two
days ago on an rpi3 and made exactly the same fix. And then another
user reported it last night:

https://github.com/ros2/ros2/issues/260

Synchronicity!

We should submit a PR with the fix to
https://github.com/eProsima/Fast-RTPS. I'll do it when I get a chance
unless somebody else gets there first.

Aptschihu Buktu

unread,
Sep 6, 2016, 3:24:14 PM9/6/16
to ROS SIG NG ROS
Yes - that's me too.
Reply all
Reply to author
Forward
0 new messages