# How to set \`runtimeDependencies\` for shared libraries?

**URL:** https://discourse.nixos.org/t/how-to-set-runtimedependencies-for-shared-libraries/14857
**Category:** Help
**Created:** [September 4, 2021, 4:22am UTC](https://discourse.nixos.org/t/how-to-set-runtimedependencies-for-shared-libraries/14857 "2021-09-04T04:22:47Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![tobiasBora](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/t/9de0a6/32.png) [@tobiasBora](https://discourse.nixos.org/u/tobiasBora)
#### Post date: [December 6, 2022, 1:42am UTC](https://discourse.nixos.org/t/how-to-set-runtimedependencies-for-shared-libraries/14857/5 "2022-12-06T01:42:26Z")

</div>

In case it can help someone, I got bitten by a similar issue as `runtimeDependencies` was not applied automatically. I actually realized that while some file were binary blob (these ones were patched correctly) the binaries that got compiled by the derivation are not fixed (which make sense…). To force to patch them, you can use something like:

```auto
    NIX_LDFLAGS = "-rpath ${lib.makeLibraryPath [libtiff]} $NIX_LDFLAGS";

```

(you can also set this variable in a phase using export + removing space around `=`)  
but note that alone it is **not enough** , as nix automatically optimize it later and removes the just added `rpath` (maybe that could explain your issue?) So avoid this unecessary optimization, just do:

```auto
dontPatchELF = true;

```

To debug, you may like:

```auto
$ readelf -d $out/lib/yourfile
…
 0x000000000000001d (RUNPATH) Bibliothèque runpath:[/nix/store/df8cvw3adyk0ip2vx6x6i0vdjyv2yinz-blablb/lib:/nix/store/4nlgxhb09sdr51nc9hdm8az5b08vzkgx-glibc-2.35-163/lib:/nix/store/mdck89nsfisflwjv6xv8ydj7dj0sj2pn-gcc-11.3.0-lib/lib]
…

```

and check what is in the RUNPATH line.

---

_[View the full topic](https://discourse.nixos.org/t/how-to-set-runtimedependencies-for-shared-libraries/14857)._
