cyberbotics / epuck_ros2

ROS2 node for the e-puck robot and its simulation model
https://cyberbotics.com/doc/guide/epuck
Apache License 2.0
57 stars 19 forks source link

Cross compilation fails on cyclonedds #26

Open sgvandijk opened 3 years ago

sgvandijk commented 3 years ago

I use your cross-compilation setup to build ROS 2 for my RPi Zero (on its own without an E-Puck) after seeing https://github.com/ros-tooling/cross_compile/issues/69#issuecomment-658865513. Thanks for this, it is a better solution than the current state of ros_cross_compile!

However, when following the cross-compilation instructions here, the cross-colcon-build command fails when trying to build the cyclonedds package with the following:

--- stderr: cyclonedds                                                                         
Starting >>> cyclonedds
--- stderr: cyclonedds
You have called ADD_LIBRARY for library ddsc without any source files. This typically indicates a problem with your CMakeLists.txt file
/opt/cross-pi-gcc/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libssl.so.1.1, needed by ../../../lib/libddsc.so.0.7.0, not found (try using -rpath or -rpath-link)
/opt/cross-pi-gcc/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: warning: libcrypto.so.1.1, needed by ../../../lib/libddsc.so.0.7.0, not found (try using -rpath or -rpath-link)
/opt/cross-pi-gcc/lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: ../../../lib/libddsc.so.0.7.0: undefined reference to `X509_STORE_CTX_get_current_cert@OPENSSL_1_1_0'
...

followed by a further list of undefined references.

I used sshfs to mount the rootfs, both libssl.so.1.1 and libcrypto.so.1.1 are there under /home/develop/rootfs/lib/arm-linux-gnueabihf, so I'm not sure why they can't be found. Probably the ADD_LIBRARY warning has something to do with it, but I couldn't immediately figure out where that comes from.

As a workaround, for now I have just disabled building this package with:

touch src/eclipse-cyclonedds/COLCON_IGNORE

with which cross-colcon-build finishes successfully.

lukicdarkoo commented 3 years ago

Thanks for this, it is a better solution than the current state of ros_cross_compile!

I wanted to merge this solution to the ros_cross_compile, but I didn't find time to adapt everything. It would be nice merging this to the ros_cross_compile.

I used sshfs to mount the rootfs, both libssl.so.1.1 and libcrypto.so.1.1 are there under /home/develop/rootfs/lib/arm-linux-gnueabihf

The sshfs may fail to deliver resources sometimes. In that case, simply running it again should solve the problem.

Have you tried installing those libraries on the Raspberry Pi (maybe sudo apt install libssl-dev libcrypto++-dev)?

Another possibility is linking those libraries directly in: https://github.com/cyberbotics/epuck_ros2/blob/master/installation/cross_compile/toolchain.cmake

Or try with -rpath as suggested in the error, but that will probably break other stuff.

Galactic is around the corner with CycloneDDS as a default middleware, so we should be prepared :)

As a workaround, for now I have just disabled building this package with:

touch src/eclipse-cyclonedds/COLCON_IGNORE

Thank you for pointing on the workaround! I am sure it will be useful to other users.

kaorusha commented 3 years ago

Thank you for the instruction, however, some package also build fail(one of them is libcurl_vendor), and I can't figure out what is path_to_pi_puck_image.img in this repo. So currently stuck here. Target OS: Raspbian GNU/Linux 10 (buster) my command

cross-colcon-build --skip-packages "console_bridge fastcdr fastrtps rti-connext-dds-5.3.1"
asherikov commented 3 years ago

This is a transitive library dependency -> libssl.so.1.1, needed by ../../../lib/libddsc.so.0.7.0, -L has no effect in this case, see man ld on -rpath-link, fixable with proper -rpath-link parameters.

lukicdarkoo commented 3 years ago

@asherikov Could you please make a PR about this?

asherikov commented 3 years ago

Sorry, no, just passing by.

SanderVanDijk-StreetDrone commented 2 years ago

I have come back to this recently. I haven't been able to find the right incantation to add -rpath-link in the correct place yet, but the following change is another workaround with which the cyclone-dds package does build, but without SSL support:

--- a/installation/cross_compile/bashrc.sh
+++ b/installation/cross_compile/bashrc.sh  
@@ -20,7 +20,8 @@ cross-colcon-build() {
         -DCMAKE_TOOLCHAIN_FILE=/home/develop/toolchain.cmake \
         -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
         -DTHIRDPARTY=ON \
-        -DBUILD_TESTING:BOOL=OFF
+        -DBUILD_TESTING:BOOL=OFF \
+        -DENABLE_SSL=OFF
 }

It now fails on foonathan_memory_vendor requiring a version of CMake that is too new, but that's separate from this issue.