Questions tagged [rpath]

rpath is an option used with the runtime linker (ld.so) to insert an RPATH header in either binaries or shared libraries. This header specifies the path search order for locating libraries.

rpath is an option used with the runtime linker on Unix and Linux (ld.so) to insert an RPATH header in either binaries or shared libraries. This header specifies the path search order for locating libraries.

The RPATH header is in the same format as the shell PATH variable, a list of directories separated by colons. There are some special tags that can be used which look like shell variables but which are really special commands to the shared library loader.

The most commonly used one is $ORIGIN which equals the current directory where the binary or shared library is located.

For instance, if I have ./x/bin/myprog and ./x/lib/libstuff.so.0 then I can make sure that myprog finds libstuff by setting its RPATH header to $ORIGIN/../lib. But if libstuff depends on libz then it will find that in /lib or /usr/lib. However, if I also set an RPATH header in libstuff.so.0 of $ORIGIN then it will first search ./x/lib for libz. Therefore I can copy libz to ./x/lib and also copy libstuff.so.0 to the same place and modify its RPATH.

If you are building and linking the software then you can control the RPATH header with the -rpath option. On linux you can also use a program named patchelf to fix it after the fact. The Solaris equivalent is elfedit. To check out current RPATH header, run readelf -d libtest.so on Linux or elfdump -d libtest.so

Setting RPATH is a polite thing to do for a self-contained app that you need to distribute to users since it helps to remove opportunities for finding incorrect versions of libraries.

219 questions
0
votes
0 answers

Qt Project Dyld Error Setting rpath

I have a Qt project and I need to include some libraries I have this in my .pro file: QT += webengine I can build and run it fine on my Mac but if I try to send the .app to someone else and they run it, there is this error: Dyld Error Message: …
0
votes
1 answer

What is the default path in .desktop files and how to change?

I am installing a package manually on my own system because I need to make some changes to it that aren't available in the basic version in my package manager. I also am trying to keep packages installed locally if possible, so I'm installing it…
cbcoutinho
  • 634
  • 1
  • 12
  • 28
0
votes
2 answers

Intel TBB Linking and RPATH

I'd like to use CMake, GTest, and Intel's TBB for a project on linux, and so far I've been able to build without complaint, but the dynamic linking required by TBB has been a bit of an issue for only one of their libraries. I'm using their CMake…
MrBZapp
  • 109
  • 7
0
votes
1 answer

How to link shared libraries in custom path directly without specifying RPATH?

I am on Ubuntu 16.04, and I am required to use an external library (MCR). It puts all of it's shared libraries inside the MATLAB/bin/glnxa64/ folder. I only need the libmx.so in there but there are libraries in there that has the exact same name as…
user3667089
  • 2,996
  • 5
  • 30
  • 56
0
votes
2 answers

Xcode does not set Runpath Search Paths to binary

I build a Xcode Application in Objective C, which uses a lot of libraries using rpath to find dependent dylibs. Now i want to add a few rpath settings to my binary, so that it always finds the corresponding libs. When i use this…
MadFisi
  • 13
  • 1
  • 6
0
votes
1 answer

How can a library / executable RPATH be patched to a different value?

I know the "search path" of an executable or library can be set using the -rpath linker option. This is useful when dependencies are installed in non-standard locations not normally considered by the object loader, and usually considered superior to…
DevSolar
  • 67,862
  • 21
  • 134
  • 209
0
votes
1 answer

Gentoo ld generates RUNPATH in library when -Wl,-rpath is used

I have such a directory structure: symlink pointing onto directory and symlink point to a library: $ libtrotl.so -> /usr/local/lib64/tora-3.1/../libtrotl.so $ instantclient -> /usr/lib/oracle/12.1/client64/lib When I dlopen library libtrotl.so, all…
ibre5041
  • 4,903
  • 1
  • 20
  • 35
0
votes
0 answers

Runtime linker, adding path to parent executable to the resolution path

I have the following sources (simplified as possible): foo.c --> the main executable ${MAIN_FOLDER}/foo, dlopens bar.so from runtime provided path. bar.c --> shared library /bar.so, dlopends baz.so from the path relative to foo baz.c -->…
ciesizdz
  • 61
  • 1
  • 5
0
votes
1 answer

dylib to dylib pathing on mac osx, how to make rpath work on mac?

We have a project which dynamically links against several dylibs. When copy the build to another mac. One need to run "otool" over the dylibs and executable in order to fix the shared library paths in them during "install". Looks like OSX had some…
znosaj88
  • 43
  • 6
0
votes
1 answer

Build RPM of Qt5 Application

predecessors. I have a trouble in building RPM from my source code. It is written in Qt5 with Qt5.7.0. My system is Fedora 24. I installed qt-opensource-linux-x64-5.7.0.run and built my code successfully. But while building RPM, I have error in…
PhonPanom
  • 385
  • 5
  • 8
0
votes
0 answers

CMake search for shared libraries in relative path

Is there a way to specify the shared library path from CMakeLists.txt? I want to make an executable which uses OpenCV but I don't want the final user to install OpenCV. Instead I would like to deliver a folder containing my executable and the shared…
lorenzo
  • 1
  • 1
0
votes
1 answer

OSX: start app with runtime-dependent dylibs

OSX 10.10 Yosemite. My application depends on Intel IPP. At compile time it depends on 2 dylibs, but these depend from other dylibs, which are loaded at runtime (and not displayed in otool -L) . When starting my application does not find these…
Vladimir Bershov
  • 2,701
  • 2
  • 21
  • 51
0
votes
1 answer

Setting LD_LIBRARY_PATH breaks my apache module, can rpath fix it?

I have an issue that requires me to set the LD_LIBRARY_PATH environment variable when running Apache (2.2) unfortunately that breaks a perfectly functioning module. I'm looking for a way to fix it and wondered if the module that I compiled myself…
HuggieRich
  • 101
  • 1
0
votes
1 answer

Can rpath value be a symbolic link?

In makefile I'm passing rpath to the linker like this -Wl,-rpath,/absolute_path_to_folder_with_lib Everything works, but when I do -Wl,-rpath,~/symlink Where ~/symlink -> /absolute_path_to_folder_with_lib The library is not loaded Can value of…
szydan
  • 2,318
  • 1
  • 15
  • 16
0
votes
0 answers

elf rpath not working (cannot open shared object file: No such file or directory)

I'm trying to get my executable to load some shared libraries from its own directory, so I decided to add . to the rpath. But when I try to run it, it doesn't find the .so. Here is the interested part of the result of readelf -d myexec : Tag …
Lectem
  • 503
  • 6
  • 19
1 2 3
14
15