Closed tjay closed 3 months ago
I'm always struggling to understand those RPATH things but given that you specify an absolute KDU_ROOT, I don't think that any RPATH setting will change it to something relative to the GDAL installation. In any case, GDAL uses standard CMake mechanisms to handle RPATH things, so I don't think we've much control on this.
As far I understand is KDU_ROOT
used to find the header files while compiling the plugin (aka /include).
https://github.com/OSGeo/gdal/blob/master/cmake/modules/packages/FindKDU.cmake
the precompiled libs have no special references:
ldd /opt/mycustomdir/lib/libkdu_v84R.so
linux-vdso.so.1 (0x00007ffee4f3a000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ff3614dd000)
libm.so.6 => /lib64/libm.so.6 (0x00007ff361402000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff3613e7000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff3611de000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff361905000)
so maybe in https://github.com/OSGeo/gdal/blob/master/frmts/jp2kak/CMakeLists.txt
there is something missing like set_target_properties(... PROPERTIES INSTALL_RPATH ...)
there is something missing like
set_target_properties(... PROPERTIES INSTALL_RPATH ...)
I'm skeptical. I let you figure it out. But I'm not sure your expectations are correct
Hi,
according to cmake.org/#LINK_INTERFACE_LIBRARIES the part from FindKDU.cmake is used wrong. KDU_LIBRARY
and KDU_AUX_LIBRARY
are always absolute Paths to .so-files. So the resulting Binary is not relocatable (independent from RPATH or LD_LIBRARY_PATH):
set_target_properties(KDU::KDU_MAIN PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${KDU_INCLUDE_DIR}/coresys/common"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${KDU_LIBRARY}")
set_target_properties(KDU::KDU_AUX PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${KDU_INCLUDE_DIR}/apps/compressed_io;${KDU_INCLUDE_DIR}/apps/jp2;${KDU_INCLUDE_DIR}/apps/image;${KDU_INCLUDE_DIR}/apps/args;${KDU_INCLUDE_DIR}/apps/support;${KDU_INCLUDE_DIR}/apps/kdu_compress"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${KDU_AUX_LIBRARY}")
My issue is fixed by overwrite the KDU_ROOT
-automatism just using the archive libraries (.a) generated from the KAKADU build, by setting:
-D KDU_INCLUDE_DIR=/tmp/v8_4 \
-D KDU_LIBRARY="/tmp/v8_4/lib/Linux-x86-64-gcc/libkdu.a" \
-D KDU_AUX_LIBRARY="/tmp/v8_4/lib/Linux-x86-64-gcc/libkdu_aux.a" \
But that might not help everyone ...
I'm not expert on these aspects but ... The absolute path in IMPORTED_LOCATION doesn't matter. But do the original libkdu .so files have a SONAME? What is the output of
objdump -p /opt/giz/mycustomdir/lib/libkdu_v84R.so | grep SONAME
AFAIU this would be the name on the left side of =>
.
@dg0yt
objdump -p /opt/giz/mycustomdir/lib/libkdu_v84R.so | grep SONAME
is empty. So there is no SONAME
.
After reading a few docs it looks like this may be the reason why dynamic linking doesn't work as expected. i will contact the deleveloper of libkakadu
.
I simply use the following to include KDU as a library:
find_path(KDU_INCLUDE_DIR kdu_args.h PATH_SUFFIXES kakadu)
find_library(KDU_LIBRARY NAMES kdu_a84R)
include_directories(${KDU_INCLUDE_DIR})
target_link_libraries(... ${KDU_LIBRARY} ...)
See https://github.com/sandflow/libench/blob/main/CMakeLists.txt
@palemieux: Is the binary file you created in this way, correctly dynamically linked? What does ldd
say on your final binary? Is there a =>
for the libkdu*.so
files, as in the "Expected behavior" from the issue description?
ldd libench
...
libkdu_a84R.so => /home/pal/.local/lib/v8_4_1-01908E/libkdu_a84R.so
@palemieux For completeness, what is the output for your case:
objdump -p /home/pal/.local/lib/v8_4_1-01908E/libkdu_a84R.so | grep SONAME
@palemieux For completeness, what is the output for your case:
objdump -p /home/pal/.local/lib/v8_4_1-01908E/libkdu_a84R.so | grep SONAME
No ouput.
Closing as likely not a GDAL bug
Building GDAL with
GDAL_SET_INSTALL_RELATIVE_RPATH=ON
or withCMAKE_INSTALL_RPATH='$ORIGIN:$ORIGIN/../lib'
these options result in all libs, except thejp2kak
-libs receiving a correctRPATH
.Expected behavior and actual behavior.
Actual behavior
Expected behavior
Steps to reproduce the problem.
the kadadu-Libs (
libkdu_v84R.so libkdu_a84R.so
) were copied to$PREFIX/lib
before build.Operating system
RHEL 9.2
GDAL version and provenance
GDAL 3.8.4