# Confusion Regarding Loading Shared Libraries

**URL:** <https://root-forum.cern.ch/t/confusion-regarding-loading-shared-libraries/36617>\
**Category:** Newbie\
**Tags:** root\
**Created:** [November 1, 2019, 8:04am UTC](https://root-forum.cern.ch/t/confusion-regarding-loading-shared-libraries/36617 "2019-11-01T08:04:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jinen](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jinen/32/20111_2.png) [@Jinen](https://root-forum.cern.ch/u/Jinen)\
**Post date:** [November 1, 2019, 8:04am UTC](https://root-forum.cern.ch/t/confusion-regarding-loading-shared-libraries/36617/1 "2019-11-01T08:04:30Z")

</div>

Dear all,

I was attempting to run sample builds of the CutLang Interpreter. The interpreter relies heavily on ROOT. The example build I tried to run compiled successfully. When I tried to run and display the output in a PDF however, it returned the following error:-

Command:  
`./showall.sh 1 histoOut-ex8.root`

Output:

```auto

Processing showall.C(1 , "histoOut-ex8.root")...
IncrementalExecutor::executeFunction: symbol '_ZN4TH1FC1ERKS_' unresolved while linking [cling interface function]!
You are probably missing the definition of TH1F::TH1F(TH1F const&)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7TCanvasC1EPKcS1_iiii' unresolved while linking [cling interface function]!
You are probably missing the definition of TCanvas::TCanvas(char const*, char const*, int, int, int, int)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7TLegendC1EddddPKcS1_' unresolved while linking [cling interface function]!
You are probably missing the definition of TLegend::TLegend(double, double, double, double, char const*, char const*)
Maybe you need to load the corresponding shared library?
IncrementalExecutor::executeFunction: symbol '_ZN7TLegend8AddEntryEPK7TObjectPKcS4_' unresolved while linking [cling interface function]!
You are probably missing the definition of TLegend::AddEntry(TObject const*, char const*, char const*)
Maybe you need to load the corresponding shared library?

```

I have no idea how to work this out. After looking through their documentation ([https://root.cern.ch/interacting-shared-libraries-rootcling](https://root.cern.ch/interacting-shared-libraries-rootcling)) I managed to find the corresponding header files (TH1F.h, TCanvas.h, TLegend.h). I successfully ran `.L Header.h+` and generated the dictionaries. (.so file extension)

I did not know how to proceed from there and executed the code with no effect. I also ran and compiled `rootcling -f DictOutput.cxx -c OPTIONS Header1.h Header2.h ... Linkdef.h` but the result was the same. In both cases the output was the same as the prior

The issue is restricted to ROOT and loading the libraries only, as running the same code on Binder ([https://mybinder.org/v2/gh/unelg/CutLang/master?urlpath=/lab/tree/binder%2Fexample1.ipynb](https://mybinder.org/v2/gh/unelg/CutLang/master?urlpath=/lab/tree/binder%2Fexample1.ipynb)) returned the correct output. Binder creates a virtual environment and had inexplicably loaded the required shared libraries.

Kindly help me fix this. Thanks in advance!

_ROOT Version:_ 6.19/01  
_Platform:_ Ubuntu 19.10

---

<div class="post-metadata">

**Author:** ![StephanH](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/c68b51/32.png) [@StephanH](https://root-forum.cern.ch/u/StephanH)\
**Post date:** [November 4, 2019, 7:39am UTC](https://root-forum.cern.ch/t/confusion-regarding-loading-shared-libraries/36617/2 "2019-11-04T07:39:36Z")

</div>

Hello,

it’s hard to see what your scripts are doing. From the error message, it seems that loading **libraries** is required, not header files as you did with `.L ??.h`.

- What are the commands being run inside the scripts?
- How did you get your root version? (Compiled manually, set up by someone, downloaded binaries, etc?)

---

<div class="post-metadata">

**Author:** ![Jinen](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jinen/32/20111_2.png) [@Jinen](https://root-forum.cern.ch/u/Jinen)\
**Post date:** [November 5, 2019, 7:07pm UTC](https://root-forum.cern.ch/t/confusion-regarding-loading-shared-libraries/36617/3 "2019-11-05T19:07:18Z")

</div>

Hey,

Yes, loading libraries is a requirement. I needed the header files to generate the dictionary (.so) files. I am unsure as to how to go about loading the created dictionaries.

I manually compiled root using cmake. All the commands I executed to build root were taken from ROOT’s documentation.

The showall.sh script primarily makes tiny modifications and proceeds to call a function showall(), which further calls showall.C, the file of which is attached below.

[showall.C](https://root-forum.cern.ch/uploads/short-url/9LEJmEoeCHCxdPbfzuLlDi6JZ8m.C) (5.9 KB)

Here is the showAll function invoked by the script:

```auto
showAll() { 
        cat ${htxtfile} | cut -f2 -d'"' | cut -f1 -d',' | grep -v Basics > histoname.txt
        root.exe -l -q -x showall.C"(${regno} , \"${rootfile}\")"
        exit 0
}

```

Thanking you for your time and assistance.

Regards,

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [November 12, 2019, 10:17pm UTC](https://root-forum.cern.ch/t/confusion-regarding-loading-shared-libraries/36617/4 "2019-11-12T22:17:17Z")

</div>

```auto
Processing showall.C(1 , "histoOut-ex8.root")... IncrementalExecutor::executeFunction: symbol '_ZN4TH1FC1ERKS_' unresolved while linking [cling interface function]! You are probably missing the definition of TH1F::TH1F(TH1F const&)

```

This is quite strange. 'TH1F’s copy constructor is part of the libHist.so library that is always automatically loaded. For example you can do:

```auto
root.exe -b -l
root [] TH1F h;

```

You can see the libraries that have been loaded via

```auto
root [8] gInterpreter->GetSharedLibs()
(const char *) "/opt/build/root_builds/master.debug/lib/libRint.so /opt/build/root_builds/master.debug/lib/libCore.so /usr/lib/libz.1.dylib /usr/lib/libsqlite3.dylib /usr/lib/libxml2.2.dylib /usr/lib/libnetwork.dylib /usr/lib/libapple_nghttp2.dylib /usr/lib/libenergytrace.dylib /usr/lib/libpcap.A.dylib /usr/lib/libcoretls.dylib /usr/lib/libcoretls_cfhelpers.dylib /usr/lib/libxar.1.dylib /usr/lib/libarchive.2.dylib /usr/lib/libbz2.1.0.dylib /usr/lib/liblzma.5.dylib /usr/lib/libmecabra.dylib /usr/lib/libcompression.dylib /usr/lib/libMobileGestalt.dylib /usr/lib/libFosl_dynamic.dylib /usr/lib/libiconv.2.dylib /usr/lib/libheimdal-asn1.dylib /usr/lib/libutil.dylib /usr/lib/libcharset.1.dylib /usr/lib/libmecab.1.0.0.dylib /usr/lib/libgermantok.dylib /usr/lib/libThaiTokenizer.dylib /usr/lib/libChineseTokenizer.dylib /usr/lib/libcmph.dylib /usr/lib/libxslt.1.dylib /usr/lib/libate.dylib /opt/build/root_builds/master.debug/lib/libRIO.so /opt/build/root_builds/master.debug/lib/libThread.so /opt/build/root_builds/master.debug/lib/libCling.so /usr/lib/libncurses.5.4.dylib /opt/build/root_builds/master.debug/lib/libMathCore.so /opt/build/root_builds/master.debug/lib/libImt.so /opt/build/root_builds/master.debug/lib/libtbb.dylib /opt/build/root_builds/master.debug/lib/libHist.so /opt/build/root_builds/master.debug/lib/libMatrix.so"

```

I wonder if the problem is not one of ‘mixed’ environment where somehow PATH and LD\_LIBRARY\_PATH do not agree on which version/build of ROOT to use.
