Undefined symbols when linking shared library

I’m trying to do a relatively simple thing. I want to expose a class of mine through a shared library so that i can use it both in CINT and (eventually) pyROOT. Note that for now this is compiled against ROOT 5.34.34 on an Ubuntu box.

The compilation of my code succeeds and I can even load the shared library using gSystem->Load(“libAnalysis”) but then during the instantiation of my class MyClass(), I get an error about a TFile method which is undefined in the shared lib.

The whole sandbox is shared on GitHub: https://github.com/zimmerst/sandbox/tree/master/ROOT/shared_lib

The Makefile includes making the dictionary based on include/LinkDef.h and the logs folder contains the output from both the Makefile and later from the CINT invocation. My suspicion is that the LinkDef.h contains too strong linker directives but I can’t figure out how top fix this.

Thank you very much for your help!


is it possible to move to ROOT6? In that case you would not even need a dictionary for interactive usage of your classes.


Hi Danilo,
This is certainly a possibility of wanted to investigate now, but it would be great if someone could provide a pointer on how to do this… ROOT changed quite a bit on this aspect. Just as a reminder though: this should be doable using native clang/gcc and not from the CINT /cling compiler.


Hi Stephan,

  • What happens when you put the object files first in the linker invocation creating libAnalysis.so?
  • Does the symbol _ZN5TFile4OpenEPKcS1_S1_ii really exist in libRIO.so? What is the output of nm lib/libRIO.so | grep _ZN5TFile4OpenEPKcS1_S1_ii?

Cheers, Axel.

Thanks Axel,
I haven’t followed up on this because in the end I solved it compiling using CINT and then importing it in python using the usual “from ROOT import Analysis” or something like that. Interestingly enough, after changing the order in the Makefile, as you suggested, I now only get a mild warning:

root [0] gSystem->Load("lib/libAnalysis")
Warning in <TClassTable::Add>: class TFile already in TClassTable


Yeah that’s a ROOT 5 quirk that we don’t have in ROOT 6 anymore.