ROOT Version: 5.28
Platform: CentOS 7
Compiler: g++4.8.5
Hello ROOTers.
I am stuck using ROOT 5, and having some trouble making ROOT CINT aware of my custom class.
I’ve compiled the class definition into a shared library, and done the following:
gSystem->Load("/mycode/lib/libStore.so")
gInterpreter->AddIncludePath("/mycode/include")
gInterpreter->ProcessLine("#include \"MyClass.h\"")
[... a few compiler warnings, just -Wsign-compare ... ]
MyClass myclass;
Error: MyClass() declared but not defined (tmpfile):1:
*** Interpreter error recovered ***
or sometimes (as usual i’ve tried many permutations at this point and somewhat lost track of things)
Error: Can't call MyClass::Set("myint",myint) in current scope (tmpfile):1:
Possible candidates are...
*** Interpreter error recovered ***
My class has templated functions, and I have managed to get it working by including the following (based on this thread):
#ifdef __CINT__
#pragma link C++ function MyClass::Set(std::string, int);
#pragma link C++ function MyClass::Set(std::string, double);
#else
template bool MyClass::Set(std::string, int);
template bool MyClass::Set(std::string, double);
#endif
This allows me to call Set<int>
and Set<double>
… but I would really like to be able to call Set<anything>
. I’ve seen other threads that seem to suggest templating ought to work.
I also tried hiding the implementation of the method from CINT as suggested here, by doing:
#ifdef __CINT__
template<typename T> bool Set(std::string, T in);
#else
template<typename T>
bool Set(std::string, T in){
/* implementation */
return true;
}
#endif
but that didn’t seem to help - I get
Error: Can't call MyClass::Set("myint",myint) in current scope (tmpfile):1:
Possible candidates are...
(in MyClass)
*** Interpreter error recovered ***
if i don’t include the #pragma
lines, and Warning: #pragma link, function Set(std::string,int) not found MyClass.h
if I do. (i also tried MAKECINT instead of __CINT__with the same result.)
I also tried building a dictionary for my class, and loading that as well (though i’m not sure if i need it? I have no need to write the objects to file), but with no change.