cross compiling causes library conflicts
Hi all!
I'm a total ROS beginner and want to compile a tutorial sample for an aarch64 target. Compiling the sample for x86_64 is working fine. In the ROS wiki I found how to start with a cross compiling project. So I created a rostoolchain.cmake like
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH /opt/ros/kinetic /usr/aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_LIBRARY_PATH /usr/lib/aarch64-linux-gnu /usr/aarch64-linux-gnu/lib)
set(CMAKE_IGNORE_PATH /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/lib/)
Starting compilation first creates a warning:
CMake Warning at rostest/CMakeLists.txt:45 (add_executable):
Cannot generate a safe runtime search path for target talker because files
in some directories may conflict with libraries in implicit directories:
runtime library [libpthread.so] in /usr/aarch64-linux-gnu/lib may be hidden by files in:
/usr/lib/x86_64-linux-gnu
Some of these libraries may not be found correctly.
A little bit later I get an error:
/usr/lib/x86_64-linux-gnu/libboost_signals.so: error adding symbols: File in wrong format
Obviously the aarch64 library file cannot be found although it is available. It seems that the linker is always trying to link the standard x86_64 library even if the CMAKE_IGNORE_PATH is set. Can anyone tell me how to exclude the standard library?
Any help is appreciated. Thanks.
If you are -accidentally- seeing wrong libs, maybe you didn't configure your cross-compiling environment correctly. What I'm trying to say is, having all libs for different architectures in the same environment isn't the best practice. I'd suggest using docker or maybe a chroot environment that doesn't have access to your 64bit libs. These ways can save you a lot of time in the future.