[Nix-dev] Why not use SONAME instead of RPATH

Wout Mertens wout.mertens at gmail.com
Wed Apr 20 23:45:09 CEST 2016


Woah I love that! +1, I don't see why we can't do that…

Wout.

On Wed, Apr 20, 2016 at 1:52 PM Silvio Frischknecht <yokto at lupux.ch> wrote:

> Hello,
>
> I recently found out that if you set the SONAME of a library to an
> absolute path.
>
> gcc --shared -Wl,-soname="$(pwd)/libxyz.so" -o libxyz.so  libxyz.c
>
> and then later link to it
>
> gcc main.c -L. -lxyz
>
> the dynamic linker will only look for the library in the exact path
> specified when compiling the library.
>
> Advantages over RPATH:
> + probably faster since rpaths in nixos tend to be quite long and every
> library has to be looked for in every folder (linear vs quadratic
> complexity)
> + only has to be setup once per library - all referrers will
> automatically work correctly
>
> In this case the path can't be overwritten by LD_LIBRARY_PATH. I guess
> that could be an advantage or a disadvantage depending on how you look
> at it.
>
> Cheers
>
> Silvio
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
-- 

Wout.
(typed on mobile, excuse terseness)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160420/83db2a6d/attachment.html 


More information about the nix-dev mailing list