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
1 answer

Gradle Native Binary linker error: bad rpath option

I have a C++ library that is being cross-compiled by Gradle on a Mac for Windows, using mingw-w64. I get a "bad -rpath option" when the linker tries to link the binaries. There are a complicated linker search paths in the debug output below that I…
John
  • 10,837
  • 17
  • 78
  • 141
0
votes
1 answer

Swift Framework not loaded

I recently completed an API Client to be used with my Swift app. I wrote the framework in a separate project, and then added the subproject to my main project, similarly to how the framework for Quick and Nimble is added to a project. When I try to…
HighFlyingFantasy
  • 3,789
  • 2
  • 26
  • 38
0
votes
0 answers

How to set gcc RPATH without including any build paths?

I need to build a wget incomplete executable using gcc for RHEL4 that will use a specific OpenSSL shared lib. LD_LIBRARY_PATH is unset at build time. This is quite simple by specifying: LDFLAGS="-W1,-rpath=/usr/local/ssl/lib…
Rob Wells
  • 36,220
  • 13
  • 81
  • 146
0
votes
2 answers

Matlab: invalid mex file library not loaded

I have created a mex function (more specifically, using CUDA) the compilation was successful, and I got a mex file zMul.mexmaci64 but on the execution, matlab reported an error: Invalid MEX-file…
Lewen
  • 1,823
  • 2
  • 15
  • 17
0
votes
0 answers

How to persuade dynamic loader to respect $LIB within RPATH in linux?

I have set the binary's rpath to the following: /usr/$LIB/test:$ORIGIN/lib/ The libraries are located at /usr/lib64/test, but when I run my binary it says it can't find those libraries. I have checked the rpath with readelf -d. The question is…
abyss.7
  • 13,882
  • 11
  • 56
  • 100
0
votes
1 answer

How do I resolve the following libtool 64-bit compilation error

I'm trying to compile the NTL library (host is 64 bit, but target platform is 32), but I'm having some trouble with libtool. The command, alongside with the output can be found in this pastebin. I know I'm doing something wrong with the rpath…
shblsh
  • 81
  • 1
  • 9
0
votes
1 answer

What assurances, if any, are given by the ELF linker for locating indirect dependencies?

Consider that I have an ELF shared library liba.so, which exports a symbol from_a. The implementation of from_a is defined in terms of a symbol from_b, which is exported from a shared library libb.so, and liba.so has a DT_NEEDED entry for libb.so. I…
acm
  • 12,183
  • 5
  • 39
  • 68
-1
votes
1 answer

"Illegal instruction" when run precompiled program on other machine

I have to build my program on CentOS 7 and deploy on other Linux machine. The program required newer version glibc, and some library which was not (and will not be) installed on target machine. So I decided to ship the executable with dynamic…
Phạm Văn Thông
  • 743
  • 2
  • 7
  • 21
-1
votes
1 answer

How to set --rpath in configure script for openssl

I have different openssl versions on my system and I don't want to install the most current openssl version into the system location - e.q. /usr/bin/openssl. Now, when I compile openssl then I get this running ldd: root => ldd…
Peter VARGA
  • 4,780
  • 3
  • 39
  • 75
1 2 3
14
15