# Error in \<TInterpreter::TCling::AutoLoad\>: failure loading library

**URL:** <https://root-forum.cern.ch/t/error-in-tinterpreter-autoload-failure-loading-library/43591>\
**Category:** ROOT\
**Tags:** cling\
**Created:** [February 17, 2021, 11:46pm UTC](https://root-forum.cern.ch/t/error-in-tinterpreter-autoload-failure-loading-library/43591 "2021-02-17T23:46:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [February 17, 2021, 11:46pm UTC](https://root-forum.cern.ch/t/error-in-tinterpreter-autoload-failure-loading-library/43591/1 "2021-02-17T23:46:10Z")

</div>

Hello ROOTers,

I have a CMake project where I compile some classes with ROOT integration. Everything works well, but in the command line interpreter, when I do:

`#include <MyClass.hpp>`

I get this error:

`Error in <TInterpreter::TCling::AutoLoad>: failure loading library libMyClass.so for libMyClass.hpp`

MyClass is a custom class that declares RQ\_OBJECT(“MyClass”) for signal-slot connections, and at the same time it derives (public) from two other non-ROOT classes. There are no ClassDef, ClassImp, LinkDef or TObject inheritance. Just the RQ macro.

In my CMakeLists.txt, I call:  
`ROOT_GENERATE_DICTIONARY(G__MyClass ${CMAKE_CURRENT_SOURCE_DIR}/MyClass.hpp)`

which correctly generates my dictionary. The slots run all well.

My library I compile with:  
`add_library(myLib SHARED utils.cpp utils.hpp MyClass.hpp MyClass.cpp G__MyClass.cxx)`

Any idea what I might be doing wrong? Why does cling look for a .so file if MyClass is not a library itself?

Here is the CMake output, no errors visible:

```auto
Generating G__MyClass.cxx, libMyClass_rdict.pcm, libMyClass.rootmap
Building CXX object CMakeFiles/myLib.dir/MyClass.cpp.o
Building CXX object CMakeFiles/myLib.dir/G__MyClass.cxx.o
Linking CXX shared library myLib.so

```

I tried doing:  
`gSystem->Load("myLib.so");`  
before calling  
`#include <ThSFMC01.hpp>`

The lib is loaded fine, but I still get the error message.

Thanks for the help.

* * *

_ROOT Version:_ 6.23/01  
_Platform:_ Ubuntu 18  
_Compiler:_ gcc

* * *

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [February 18, 2021, 12:08am UTC](https://root-forum.cern.ch/t/error-in-tinterpreter-autoload-failure-loading-library/43591/2 "2021-02-18T00:08:54Z")

</div>

Also, I see that there is some .so being defined inside the CMake directory, although it does not generate it.

```auto
CMakeFiles/myLib.dir/build.make:	cd build && /snap/cmake/793/bin/cmake -E env LD_LIBRARY_PATH=/opt/root_bld/lib: /opt/root_bld/bin/rootcling -v2 -f G__MyClass.cxx -s libMyClass.so -rml libMyClass.so -rmf libMyClass.rootmap -Iinclude -I/opt/root_bld/include MyClass.hpp
CMakeFiles/G __MyClass.dir/build.make:	cd build && /snap/cmake/793/bin/cmake -E env LD_LIBRARY_PATH=/opt/root_bld/lib: /opt/root_bld/bin/rootcling -v2 -f G__ MyClass.cxx -s libMyClass.so -rml libMyClass.so -rmf libMyClass.rootmap -Iinclude -I/opt/root_bld/include MyClass.hpp
libMyClass.rootmap:[libMyClass.so]

```

Or something is wrong with the Generate dictionary CMake macro?

---

<div class="post-metadata">

**Author:** ![etejedor](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/e79b87/32.png) [@etejedor](https://root-forum.cern.ch/u/etejedor)\
**Post date:** [February 18, 2021, 8:50am UTC](https://root-forum.cern.ch/t/error-in-tinterpreter-autoload-failure-loading-library/43591/3 "2021-02-18T08:50:08Z")

</div>

Hello,

If you generate the dictionaries, you should not need to include the header (`MyClass.hpp`) in the ROOT prompt, just load the library `myLib`. Does that also show you the message?

Also in

```auto
 add_library(myLib SHARED utils.cpp utils.hpp MyClass.hpp MyClass.cpp G__MyClass.cxx)

```

You don’t need to include the header you used to generate the dictionary (`MyClass.hpp`), according to what I see in :

> **[Python interface: PyROOT](https://root.cern/manual/python/#loading-c-libraries-with-dictionaries)**
>
> Data Analysis Framework

But surely @Axel will know better.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [February 18, 2021, 9:12am UTC](https://root-forum.cern.ch/t/error-in-tinterpreter-autoload-failure-loading-library/43591/4 "2021-02-18T09:12:04Z")

</div>

Thanks, not doing “include” solves it!

---

<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:** [March 4, 2021, 9:12am UTC](https://root-forum.cern.ch/t/error-in-tinterpreter-autoload-failure-loading-library/43591/5 "2021-03-04T09:12:21Z")

</div>

Closed on March 4, 2021, 9:12am UTC

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