#Portable rpath for a dynamically linked library

1 messages · Page 1 of 1 (latest)

hexed sapphire
#

I produce an executable and a dynamic library.
The executable needs to link to the dynamic library.
If i only do exe.linkLibrary(dynlib), the executable is not able to find the library outside the project directory.
So i'm guessing i should do something like exe.root_module.addRPath("something portable...")

But what should it be? something with $ORIGIN?

twin lotus
#

well, where is it gonna end up?

#

u can't really set the rpath without knowing how it's gonna be installed by the end user

hexed sapphire
#

install_prefix/... ?

twin lotus
#

this is one of many reasons dynamic libs suck

#

is there a reason it has to be dynamically linked?

hexed sapphire
#

well maybe not

twin lotus
#

if u can make it a static lib, ur life will become 20x easier

hexed sapphire
#

the library is dynamic because it can be used by any program wanting to use it

#

and my exe is using it itself but i guess it could be a static library for the exe

twin lotus
#

static libs are way better for distribution unless u have full control over the installation process (eg. when packaging for a distro package manager)

#

they also result in smaller download sizes (cuz only the bits that are needed are linked), faster startup time (cuz no need to wait around for ld-linux), faster execution (cuz of lto), etc etc

hexed sapphire
#

yes i'll try and make both the dynlib for third party use, and static lib for the exe

#

but i'm still curious if could have done something like exe.root_module.addRPath(install_prefix/...)

twin lotus
#

if u use zig build --prefix it should work automatically I would think? maybe it doesn't

#

or u might need to set up some weird dependency order or smth, idk