I would like to write a class which I can store into a TFile, hence I inherit TNamed and apply ClassDef/ClassImp.
Now, this class inherits another purely abstract inteface a la
class Interface {
public:
void doSomething() = 0;
};
class MyClass : public TNamed, public Interface { };
Now if I compile the class in CINT with
.L MyCkass.cpp+
and try to retrieve it from the file
MyClass* c = (MyClass*)file->Get(“MyClassName”)
I get the following error message:
Processing Test.C…
Warning in TClass::TClass: no dictionary for class Interface is available
Warning in TStreamerInfo::Build:: MyClass: base class Interface has no streamer or dictionary it will not be saved
Fatal in TStreamerInfo::: fv < 30000 violated at line 434 of `meta/src/TStreamerInfo.cxx’
aborting
did not generate the dictionary for the class Interface.
I suspect that you have a file Interface.h which define the class Interface.
By default ACLiC, i.e
, generate dictionaries only for C++ constructs defined in the file MyCkass.cpp and MyCkass.h and hence do not generate the dictionary for the class Interface if it is not defined in MyCkass.h (even if it is included).
To generate the dictionary for Interface you can either do:
or add the lines
#ifdef __MAKECINT__
#pragma link C++ class Interface+;
#endifto MyCkass.h
Thanks, I indeed had solved the problem by generationg the Interface_hpp.so first.
But I like the second solution you suggest a lot better, I’ll try that! (Especially becasue it means I will have only one shared library floating around, right?)
Can I actually somehow put mutiple classes defined and implemented in mulitple *.cpp and *.h files into one shared library? I have a ‘circular dependency’ a la
Mother.h:
class Daugher;
class Mother {
private:
Daughter* _daughter;
};
Daughter.h:
class Mother;
class Daughter {
private:
Mother* _mother;
};
What you request is possible AND RECOMMENDED.
One dictionary per class is expensive because there is a constant overhead per dictionary.
Create a LinkDef.h file with a pragma statement for all the classes you want to group in the same shared lib.
In the rootcint command specify the list of all includes defining these classes.
You can see examples in the Root Makefile
or in $ROOTSYS/test/Makefile
The solution is to use an extra file (bundle.C) containing:
// Start of bundle.C
#include "Mother.h"
#include "Daugher.h"
#ifdef __MAKECINT__
#pragma link C++ class Mother+;
#pragma link C++ class Daughter+;
#endif
and do