I have a class with a member whose type is a std::vector<std::vector > *ptr. I want to store this variable as a branch in my tree. I do this using the method
and this creates the exe, as expected. When I try to run the exe, I get the runtime errors
Error in <TTree::Branch>: The class requested (vector<vector<float> >) for the branch "branchName" refer to an stl collection and do not have a compiled CollectionProxy. Please generate the dictionary for this class (vector<vector<float> >)
Any reason why this is happening, even though I #include and link with the appropriate standard library?
BTW. The “#pragma link C++” is irrelevant for the compiler when you compile your class’es source code. You would need to call “rootcint” in order to build the dictionary for your class. A separate additional source code file would be created which you would need to compile and add that additional object file to the linker command line.
A brutal fix …
… assuming that the class’es source code file is “MyClass.cxx”, execute: echo 'gROOT->LoadMacro("MyClass.cxx++"); gSystem->Exit(0);' | root -b -l -n … or … root -b -l -n <<EOF
.L MyClass.cxx++
.q
EOF This will (hopefully) create a “MyClass_cxx.so” shared library file (it should include the class’es dictionary and all “#pragma link C++” related ones as well). Add this “MyClass_cxx.so” shared library file (you can also rename it into something like a “libMyClass.so”, if you like) to the link command line instead of the “MyClass.o” file (no need to compile the “MyClass.cxx” file itself separately at all).