On Sun, Apr 7, 2024 at 5:22 PM Damjan Jovanovic <dam...@apache.org> wrote:

>
>
> On Sun, Apr 7, 2024 at 2:26 PM Arrigo Marchiori <ard...@apache.org> wrote:
>
> Honestly, I don't know in detail what RPATH is and how to change it,
>> and I would like to adopt the simplest approach to the problem.
>>
>
> It is a ":"-separated list of paths where the binary's dependencies are
> searched for, before trying the system paths. If it contains $ORIGIN at the
> beginning, then in the case of executables, it is the directory containing
> the executable, and in the case of libraries, it is the directory of the
> executable that loaded them. You can see how this is useful: it allows
> OpenOffice to be installed anywhere in the filesystem, and binaries can
> still find their internal dependencies, because their paths are relative to
> wherever the executable is, instead of some hardcoded location.
>
> In theory, you pass these options to the compiler when linking:
> -Wl,-z,origin -Wl,-rpath,$ORIGIN
> where -Wl,-z,origin enables the use of $ORIGIN in the path, and
> -Wl,-rpath,$ORIGIN specifies the path, in this case being the directory
> containing the executable.
> In practice, however, getting that "$" past dmake and 3 layers of shell
> quoting and escaping, is impossibly difficult.
>

Here's how you set RPATH in Curl:

---snip---
diff --git a/main/curl/makefile.mk b/main/curl/makefile.mk
index 044bf4d8c9..ecef11820a 100644
--- a/main/curl/makefile.mk
+++ b/main/curl/makefile.mk
@@ -59,6 +59,7 @@ curl_LDFLAGS+:=$(ARCH_FLAGS)
 ssl_param=--with-ssl
 .ELSE
 ssl_param=--with-ssl=$(OUTDIR)
+curl_LDFLAGS+=-Wl,-z,origin -Wl,-rpath,\\\$$\$$ORIGIN
 PATCH_FILES+= curl-bundled_openssl.patch
 .ENDIF

---snip---

which gets libcurl.so to search for the OpenSSL dynamic libraries in its
own directory before the system directories:

$ ldd solver/450/unxfbsdx.pro/lib/libcurl.so
...
libssl.so.3 => /path/to/openoffice-git/main/solver/450/
unxfbsdx.pro/lib/libssl.so.3 (0x299f766bc000)
libcrypto.so.3 => /path/to/openoffice/openoffice-git/main/solver/450/
unxfbsdx.pro/lib/libcrypto.so.3 (0x299f77747000)

Regards
Damjan

Reply via email to