# Differences between LD\_LIBRARY\_PATH and ROOT\_LIBRARY\_PATH

**URL:** <https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036>\
**Category:** ROOT\
**Created:** [October 24, 2026, 10:13am UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036 "2026-10-24T10:13:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicola\_Mori](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nicola_mori/32/23583_2.png) [@Nicola\_Mori](https://root-forum.cern.ch/u/Nicola_Mori)\
**Post date:** [October 24, 2026, 10:13am UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036/1 "2026-10-24T10:13:12Z")

</div>

I’m using Root 6.36.10 in an environment compiled with Spack, so LD\_LIBRARY\_PATH is empty but ROOT\_LIBRARY\_DIR correctly dontains the path of the lib/ folder of the environment. When trying to load a dynamic library from the shell I get:

```auto
# echo $LD_LIBRARY_PATH

# echo $ROOT_LIBRARY_PATH 
/software/spack/var/spack/environments/gseagen/.spack-env/view/lib/root:/software/spack/var/spack/environments/gseagen/.spack-env/view/lib64:/software/spack/var/spack/environments/gseagen/.spack-env/view/lib
# root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.36.10 https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Oct 16 2026, 09:39:39 |
  | From tags/6-36-10@6-36-10 |
  | With g++ (Spack GCC) 15.2.0 |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] .L lib/libGPhQELEG-3.06.02.so
cling::DynamicLibraryManager::loadLibrary(): /software/install/linux-x86_64_v3/genie-3.6.2-uixeqzr6zjwsgzhqshqsquu2kzy2gqo2/lib/libGPhQELEG-3.06.02.so: undefined symbol: _ZTIN5genie22KineGeneratorWithCacheE

```

If I set the lib/ libraries to `LD\_LIBRARY\_PATH it works instead:

```auto
# export LD_LIBRARY_PATH=$ROOT_LIBRARY_PATH
# root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.36.10 https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Oct 16 2026, 09:39:39 |
  | From tags/6-36-10@6-36-10 |
  | With g++ (Spack GCC) 15.2.0 |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] .L lib/libGPhQELEG-3.06.02.so
root [1] 

```

According to [this post](https://root-forum.cern.ch/t/add-search-path-for-dictionaries/62726/2) I initially thought that the two variables play the same role for Cling, with the Root-specific one available to avoid potential side effects with other applications using `LD_LIBRARY_PATH`, but my tests show that it’s not the case.  
So what are the differences and the intended usage withing Cling of the two variables? Thanks.

---

<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:** [October 24, 2026, 4:39pm UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036/2 "2026-10-24T16:39:42Z")

</div>

ROOT will search for some requested shared library in the “`ROOT_LIBRARY_PATH`”. Still, this variable will NOT be used by the dynamic linker to find and load other shared libraries that your requested shared library depends on. The dynamic linker will only see shared libraries in the “`LD_LIBRARY_PATH`” (and “`RPATH`” and “`RUNPATH`” set in your requested shared library, of course).

See also (try the “[brutal fix](https://root-forum.cern.ch/t/cling-loadlibrary-severely-broken/45924/8)”):

> [@cling::DynamicLibraryManager::loadLibrary severely broken](https://root-forum.cern.ch/t/cling-loadlibrary-severely-broken/45924):
>
> @Axel This is Ubuntu 20.04 / x86\_64 / gcc 9.3.0 and ROOT 6.24/02. I have a bunch of shared libraries which I try to load using: root [0] gSystem-\>AddDynamicPath("/.../VTK-9.0/lib") root [1] gSystem-\>Load("libvtkCommonCore-9.0") cling::DynamicLibraryManager::loadLibrary(): libvtksys-9.0.so.1: cannot open shared object file: No such file or directory (int) -1 However, the “missing” library DOES exist in the same directory, as can be proven by: root [2] gSystem-\>Load("libvtksys-9.0.so.1") (int)…

BTW. You also mention the “`ROOT_LIBRARY_DIR`” variable, but this is a configure/compile-time variable, not a run-time one.

---

<div class="post-metadata">

**Author:** ![Nicola\_Mori](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nicola_mori/32/23583_2.png) [@Nicola\_Mori](https://root-forum.cern.ch/u/Nicola_Mori)\
**Post date:** [October 25, 2026, 4:19pm UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036/3 "2026-10-25T16:19:18Z")

</div>

Sorry, `ROOT_LIBRARY_DIR` was a mistake and I always meant `ROOT_LIBRARY_PATH`. I checked your answer and it makes sense, except for one thing. In he following, contrary to the first post, I did everything outside a spack environment, so env variables and RPATHs coincide.

The library I am trying to load is in a folder included in `ROOT_LIBRARY_PATH`, and it has RPATHS for all the folders containing its dependency libraries, including the one defining the missing symbol Cling complains about:

```auto
$ unset LD_LIBRARY_PATH

$export MYLIBFOLDER=/home/mori/software/spack/opt/spack/linux-skylake/genie-3.6.2-3ghintdjrgcx6o2iq7rd6vcc26zj6f3a/lib

$ echo $ROOT_LIBRARY_PATH | grep -o $MYLIBFOLDER
1:/home/mori/software/spack/opt/spack/linux-skylake/genie-3.6.2-3ghintdjrgcx6o2iq7rd6vcc26zj6f3a/lib

$ ls $MYLIBFOLDER/libGPhQELEG-3.06.02.so
/home/mori/software/spack/opt/spack/linux-skylake/genie-3.6.2-3ghintdjrgcx6o2iq7rd6vcc26zj6f3a/lib/libGPhQELEG-3.06.02.so

$ nm $MYLIBFOLDER/libGPhCmn-3.06.02.so | grep _ZTIN5genie22KineGeneratorWithCacheE
638:00000000000474e8 V _ZTIN5genie22KineGeneratorWithCacheE

$ readelf -d $MYLIBFOLDER/libGPhQELEG-3.06.02.so | grep -E 'RPATH|RUNPATH' | grep -o $MYLIBFOLDER 
1:/home/mori/software/spack/opt/spack/linux-skylake/genie-3.6.2-3ghintdjrgcx6o2iq7rd6vcc26zj6f3a/lib

$ root
root [0] .L $MYLIBFOLDER/libGPhQELEG-3.06.02.so
cling::DynamicLibraryManager::loadLibrary(): /home/mori/software/spack/opt/spack/linux-skylake/genie-3.6.2-3ghintdjrgcx6o2iq7rd6vcc26zj6f3a/lib/libGPhQELEG-3.06.02.so: undefined symbol: _ZTIN5genie22KineGeneratorWithCacheE

```

From the above you can see that the library I’m trying to load and the one containing the missing symbol are in the same folder. Being `LD_LIBRARY_PATH` undefined Cling starts loading the first looking in `ROOT_LIBRARY_PATH`, and then ld.so should look at its RPATH to load the second. From the second to last instruction above you can see that the RPATH actually contains the folder containing all the libraries involved, but still Cling fails. The only way I found to make it work is to add the folder to `LD_LIBRARY_PATH`.

I might have not understood your explanation, but as far as I did it does not match with the above results.

---

<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:** [October 25, 2026, 5:02pm UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036/4 "2026-10-25T17:02:11Z")

</div>

It looks like your “`libGPhQELEG`” was NOT linked against your “`libGPhCmn`” (which provides the “`typeinfo for genie::KineGeneratorWithCache`”), so the dynamic linker does not know that it needs to load it, too.  
Try: “`ldd $MYLIBFOLDER/libGPhQELEG-3.06.02.so`”

I think you have the required files “`$MYLIBFOLDER/*.pcm`” (and/or “`*.rootmap`”). ROOT will find them only if your “`$MYLIBFOLDER`” is in your “`LD_LIBRARY_PATH`” (“`ROOT_LIBRARY_PATH`” is not sufficient in this case, as far as I know).

@pcanal @Danilo It seems to me that it would be a good idea to have ROOT search for the “`*.pcm`” and “`*.rootmap`” files in the directories specified by the “`ROOT_LIBRARY_PATH`” (in addition to the “`LD_LIBRARY_PATH`”).

---

<div class="post-metadata">

**Author:** ![Nicola\_Mori](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nicola_mori/32/23583_2.png) [@Nicola\_Mori](https://root-forum.cern.ch/u/Nicola_Mori)\
**Post date:** [October 26, 2026, 8:04am UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036/5 "2026-10-26T08:04:58Z")

</div>

Thank you, now I think I understand. Effectively these libraries I’m using have not been linked against each other (it’s a 3rd-party software). This poses another more subtle problem related to spack: I can fix the library loading issue by adding the needed folder to LD\_LIBRARY\_PATH, but in this way when I activate a spack environment containing that library LD\_LIBRARY\_PATH will be set to the lib/ folder of the environment which contains a load of packages, in particular also some equivalent of the system packages which now will be used by all the programs, not just the spack-built ones, instead of the system-installed ones. This already generates errors in my system, how can I circumvent this?

---

<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:** [October 26, 2026, 8:31am UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036/6 "2026-10-26T08:31:33Z")

</div>

I am not a Spack expert (maybe you need to talk to the authors of the “gseagen view”).

From what you write, it seems to me that you only need to add this single (“GENIE” related) directory to the “`LD_LIBRARY_PATH`”, so maybe you could initialize your Spack “view” first and then modify this variable.

I remember cases where I was unable to run “vi” when some “additional” environment was initialized.  
In such “problematic” cases, I always open a separate terminal and initialize the environment there. And then in this terminal, I only work with the utilities specific to this environment (other actions are performed in another “standard” terminal).

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 9, 2026, 8:31am UTC](https://root-forum.cern.ch/t/differences-between-ld-library-path-and-root-library-path/65036/7 "2026-11-09T08:31:55Z")

</div>

Closed on November 9, 2026, 8:31am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
