# Load different Libraries (VTK Libraries) to the Root

**URL:** <https://root-forum.cern.ch/t/load-different-libraries-vtk-libraries-to-the-root/45889>\
**Category:** ROOT\
**Created:** [July 17, 2021, 7:17pm UTC](https://root-forum.cern.ch/t/load-different-libraries-vtk-libraries-to-the-root/45889 "2021-07-17T19:17:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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 17, 2021, 7:45pm UTC](https://root-forum.cern.ch/t/load-different-libraries-vtk-libraries-to-the-root/45889/2 "2021-07-17T19:45:18Z")

</div>

Create a simple “`rootlogon.C`” file (in your current working directory):

```cpp
{ // rootlogon.C
  gInterpreter->AddIncludePath("/where/are/your/VTK/includes");
  gSystem->AddDynamicPath("/where/are/your/VTK/libs");
  // load all "libvtk*.so" shared libraries (no need to append ".so" in names)
  // note: if they depend on one another, the order matters; e.g., try to
  // load them in the same order as they had been built: "ls -1rt libvtk*.so"
  gSystem->Load("libvtkCommonColor-9.0");
  gSystem->Load("libvtkFiltersSources-9.0");
  gSystem->Load("libvtklz4-9.0");
  // ...
  gSystem->Load("libvtkpng-9.0");
  gSystem->Load("libvtkCommonMisc-9.0");
  gSystem->Load("libvtkImagingGeneral-9.0");
}

```

You probably do not need to load all “`libvtk*.so`” libraries one by one. There are probably only several “top-level” libraries that you need to load “manually”. When they were being built, each of these “top-level” libraries was linked against “lower-level” libraries on which it depends. So, when you load such a “top-level” library, the system will automatically load all required “lower-level” libraries (that it knows about, of course).  
Note however that, due to a [known cling::DynamicLibraryManager deficiency](https://root-forum.cern.ch/t/cling-loadlibrary-severely-broken/45924), you need to add the “`/where/are/your/VTK/libs`” directory into the “`LD_LIBRARY_PATH`” environment variable (before starting `root`), or you need to run (just once):  
`patchelf --set-rpath "\$ORIGIN" /where/are/your/VTK/libs/libvtk*.so`

---

_[View the full topic](https://root-forum.cern.ch/t/load-different-libraries-vtk-libraries-to-the-root/45889)._
