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.
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?