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

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:

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


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

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?

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

 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 :

But surely @Axel will know better.

Thanks, not doing “include” solves it!

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