ROOT libraries not loaded at start

Hi Wim,

I’m attempting to load a standalone compiled library into PyROOT and was encountering some strangeness with missing symbols. In investigating this, I found that if I manually loaded a library with the missing symbol I was able to successfully load my standalone library.

import ROOT
ROOT.gSystem.Load(‘libPileupReweighting’)
Message: (file “libPileupReweighting.so”, line -1) dlopen error: /home/peter/gitstuff/analyses/external/PileupReweighting/StandAlone/./libPileupReweighting.so: undefined symbol: _ZTI3TH2
Traceback (most recent call last):
File “”, line 1, in
RuntimeError: (file “libPileupReweighting.so”, line -1) Failed to load Dynamic link library /home/peter/gitstuff/analyses/external/PileupReweighting/StandAlone/./libPileupReweighting.so
ROOT.gSystem.Load(‘libSessionViewer’)
0
ROOT.gSystem.Load(‘libPileupReweighting’)
0

I’m not sure I understand the details of what is going on, but I would expect that ROOT loads some standard libraries on import. Why is libSessionViewer not one of these?

Thank you sincerely for your help,

Peter

Peter,

_ZTI3TH2 is ‘typeinfo for TH2’ which lives in libHist.so. Either link with that library, or make sure it’s mentioned in the rootmap file for the classes that you are interested in and then rely on the auto-loader.

Cheers,
Wim

Hi Wim,

Below is the linking done in the Makefile:

g++ -L/opt/ROOT/v5-34-00-patches/lib -lHist -lMatrix -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -O2 -Wall -fPIC -pthread -m64 -I/opt/ROOT/v5-34-00-patches/include -shared …/Root/TPileupReweighting.o …/Root/TPileupReweightingCint.o -o …/StandAlone/libPileupReweighting.so

It looks like this is linking with libHist, and /opt/ROOT/v5-34-00-patches/lib is in LD_LIBRARY_PATH. Is there something off about the above? This may be out of the scope of ROOT/PyROOT, so please let me know if I need to find another source of information.

Thanks again for your help,

Peter

Hi Again,

I figured out the issue, and it has nothing to do with ROOT/PyROOT but I thought I’d include an explanation in case anyone encounters a similar issue. The compiler optimized the linking to include only those libraries it knows it needs. The way the compiler knows which it needs are those that are asked for in front of it in the command line arguments. The correct g++ linking command for my case is:

g++ …/Root/TPileupReweighting.o …/Root/TPileupReweightingCint.o -L/opt/ROOT/v5-34-00-patches/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -O2 -Wall -fPIC -pthread -m64 -I/opt/ROOT/v5-34-00-patches/include -shared -o …/StandAlone/libPileupReweighting.so

My .o files must come first since they are the ones requesting ROOT libraries.

This can be considered solved or removed for being off-topic.

Thanks,

Peter

1 Like