Generating genreflex dicts: troubles with funcs inside class

Good evening,

I would like to build a dict.so library to be loaded into PyROOT, but I have troubles generating the genreflex dict from a custom class.

I have no errors during the compilation and the dict generation, but when I try to load the library , I get an “undefined symbol” error, both with interactive Cint and interactive Python.

Basically I have several .h files, defining classes, structs and functions inside a same namespace.
And the problem seems to be with the functions declared inside classes or structs defined within the namespace. In fact the “undefined symbols” errors are all related to function names belonging to classes.

I put an extract of my code attached, just to replicate the errors.
You can find the selection.xml file inside the tar file.

I generate the dict with:

/afs/cern.ch/sw/lcg/app/releases/ROOT/5.22.00d/slc4_ia32_gcc34/root/bin/genreflex myDict.h --deep -s selection.xml -o LCGdict.cc -I $ROOTSYS/include

Obtaining this output:

--->> genreflex: INFO: Parsing file myDict.h with GCC_XML OK
--->> genreflex: INFO: Generating Reflex Dictionary
class CppTools::DefinitionsCSC
class CppTools::JetCuts
function CppTools::IsVetoed(TRootPhoton const&, TRootJet const&, CppTools::PhotonCuts const&)
function CppTools::IsVetoed(TRootMuon const&, TRootJet const&, CppTools::MuonCuts const&)
function CppTools::IsVetoed(TRootElectron const&, TRootJet const&, CppTools::ElectronCuts const&)
function CppTools::IsSelected(TRootTauJet const&, CppTools::TauCuts const&)
function CppTools::IsSelected(TRootJet const&, CppTools::JetCuts const&)
function CppTools::IsSelected(TRootMuon const&, CppTools::MuonCuts const&)
function CppTools::IsSelected(TRootPhoton const&, CppTools::PhotonCuts const&)
function CppTools::IsSelected(TRootElectron const&, CppTools::ElectronCuts const&)
function CppTools::IsOverlapping(TRootMuon const&, TRootTauJet const&, CppTools::TauCuts const&)
function CppTools::IsOverlapping(TRootElectron const&, TRootTauJet const&, CppTools::TauCuts const&)
function CppTools::IsOverlapping(TRootJet const&, TRootTauJet const&, CppTools::TauCuts const&)
function CppTools::IsOverlapping(TRootJet const&, TRootPhoton const&, CppTools::PhotonCuts const&)
function CppTools::IsOverlapping(TRootJet const&, TRootElectron const&, CppTools::ElectronCuts const&)
function CppTools::GetFourVector(TRootParticle const&)

So all plain functions inside the namespace are generated, plus two classes. But the functions inside the classes are not taken into account by the dict generation.

The I compile it without any errors with:

g++ myDict.h LCGdict.cc -o libmylib.so  `root-config --cflags --libs`  -lReflex -lCintex -shared

and I get an error when I tried to load it :

root [0] gSystem->Load("libCintex.so");Cintex::Enable();
root [1] gSystem->Load("libmylib.so");
dlopen error: /home/rbianchi/eclipse-workspaces/eclipse_workspace_default/WatchMan/trunk/python/interface/delphes/cpptools/CppTools/example/./libmylib.so: undefined symbol: _ZN8CppTools14DefinitionsCSCC1Ev
Load Error: Failed to load Dynamic link library /home/rbianchi/eclipse-workspaces/eclipse_workspace_default/WatchMan/trunk/python/interface/delphes/cpptools/CppTools/example/./libmylib.so
*** Interpreter error recovered ***
root [2]

If I remove the “DefinitionsCSC” class from the selection.xml, then I get the same error with a function isnde the other class “JetCuts”:

root [0] gSystem->Load("libCintex.so");Cintex::Enable();
root [1] gSystem->Load("libmylib.so");
dlopen error: /home/rbianchi/eclipse-workspaces/eclipse_workspace_default/WatchMan/trunk/python/interface/delphes/cpptools/CppTools/example/./libmylib.so: undefined symbol: _ZN8CppTools7JetCuts15StandardJetCutsEv
Load Error: Failed to load Dynamic link library /home/rbianchi/eclipse-workspaces/eclipse_workspace_default/WatchMan/trunk/python/interface/delphes/cpptools/CppTools/example/./libmylib.so
*** Interpreter error recovered ***
root [2] 

If I use c++filt I get:

echo _ZN8C
ppTools14DefinitionsCSCC1Ev | c++filt
CppTools::DefinitionsCSC::DefinitionsCSC()

and:

echo _ZN8CppTools7JetCuts15StandardJetCutsEv | c++filt
CppTools::JetCuts::StandardJetCuts()

Could you help me?

Thanks a lot,

Ric.

p.s. A doubt came to me just now… :slight_smile: :stuck_out_tongue:
Should I “inlclude” the .cxx source files in some ways, during the dict generation or the compilation?
And How?

Thanks again!!! :slight_smile:
example.tar.gz (8.32 KB)

[quote]Should I “inlclude” the .cxx source files in some ways, during the dict generation or the compilation? [/quote]In most case yes, it is likely that file contains the implementation that are missing. So you need to make sure that the .cxx is compiled and linked as part of the shared library.

Cheers,
Philippe.

Thanks Philippe! :slight_smile:

I answered you on the other post. As you told, it was a linking problem.
Now it works fine!

Thanks again!! :slight_smile:

Ric.