Linux: Can't find existing shared library in docker container
The last edit led to the issue and also to the solution.
CMake removes the RPATH
. In case of the usage within a docker container, this stripping makes no sense and can be turned off as described in this post by adding this argument to the CMake configuration call:
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE
At the end my Dockerfile looks like this:
FROM fastrtps-coreWORKDIR /optRUN git clone https://github.com/eProsima/Fast-RTPS.git && \ export LDFLAGS="-Wl,--copy-dt-needed-entries" && \ mkdir build && \ cd build && \ cmake ../Fast-RTPS/examples \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE && \ cmake --build . --target install -j 16 && \ cd /opt && \ rm -rf build Fast-RTPS
Now the install-step output shows the correct runtime-path setting:
-- Installing: /usr/local/examples/C++/HelloWorldExample/HelloWorldExample-- Set runtime path of "/usr/local/examples/C++/HelloWorldExample/HelloWorldExample" to "/usr/local/lib"