# cling::DynamicLibraryManager::loadLibrary severely broken

**URL:** <https://root-forum.cern.ch/t/cling-loadlibrary-severely-broken/45924>\
**Category:** ROOT\
**Created:** [July 20, 2021, 9:54am UTC](https://root-forum.cern.ch/t/cling-loadlibrary-severely-broken/45924 "2021-07-20T09:54:20Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 21, 2021, 8:25pm UTC](https://root-forum.cern.ch/t/cling-loadlibrary-severely-broken/45924/8 "2021-07-21T20:25:30Z")

</div>

I have found a brutal fix that may be of interest to other people.

It works on Linux for shared libraries in the default ELF format (I do not know any fix for macOS and / or Windows, sorry).

The trick is to add “`$ORIGIN`” to their “`RUNPATH`”.

After building the VTK software and executing “make install”, I have around 160 shared libraries in a single directory ("`/.../VTK-9.0/lib`" in my previous posts here). By default, these libraries do not have any “`RUNPATH`” set, so I could simply execute:

```bash
patchelf --set-rpath "\$ORIGIN" *.so

```

Note: the above command unconditionally sets the new “`RUNPATH`” so one should first make sure that it is really empty:

```bash
readelf -d *.so | egrep "File:|RPATH|RUNPATH"

```

If for “`libSomeLibrary.so`” one sees some non-empty “`old_value`” then for this library one should execute:

```bash
patchelf --set-rpath "old_value:\$ORIGIN" libSomeLibrary.so

```

---

_[View the full topic](https://root-forum.cern.ch/t/cling-loadlibrary-severely-broken/45924)._
