colcon-core
colcon-core copied to clipboard
Colcon extends LD_LIBARAY_PATH with cross compiled libraries
I am trying to cross compile rosbag2 for QNX 7.2 on Ubuntu Jammy. If I do so, cmake crashes for packages which depend on zstd_vendor with this error
/usr/bin/cmake: error while loading shared libraries: libc.so.5: cannot open shared object file: No such file or directory
The reason for that is that:
- QNX 7.2 ships with libc.so.5
- Ubuntu Jammy ships with libc.so.6
- QNX and Linux both use ELF as their file format for executable files
- zstd_vendor build libzstd.so
- CMake links agains libzstd.so
- Colcon adds libraries build in dependencies to LD_LIBARARY_PATH
- This results for packages which depend on zstd_vendor to in cmake trying to load libzstd.so from zstd_vendor. This will fail because this version of libzstd.so is build against libc.so.5 - which is not available on Ubuntu Jamme and therefore results in a failure.
I was able to circumvent this issue by reconfiguring zstd_vendor so that is creates static libraries in stead of shared libraries. However, this issue concernes me a bit. It should be possible to cross compile projects using Colcon without the potential risk of injecting newly build libraries into the build system.
At this point I'm not entirely sure how to fix this issue. My first idea was to have some kind of "cross compilation flag" which turns this "LD_LIBRARY_PATH" behavior off entirely during build time. However, as think more about it: in general it should not be possible that parts of the build system end up using just build libraries by accident - this seems just wrong to me.