LinkDef in my own library

Hello guys,

I created my own library using root.
It contains a class that I will call MyClass.

This class contains a private pointer to TH1D. When I compile MyClass there is no problem.
Furthermore I can use it in my compiled root program without any trouble.
When I compile MyClass in a library .so and load it in a interactive root session I got this message error:
dlopen error: /afs/…/lib/ undefined symbol: _ZTI4TH1D
Load Error: Failed to load Dynamic link library /afs/…/lib/

When I remove the pointer to TH1D in MyClass about which I spoke the error disappears.
I suppose it is a LinkDef.h error, but I don’t know if I have to write something more about TH1D* in my LinkDef.h file :
#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class MyClass;

Hope this is clear, and that you will be able to help me!

Best Regards,

The “_ZTI4TH1D” is the “typeinfo for TH1D” -> I hope you:
#include "TH1.h"
in the “MyClass.h” interface file.

I’m not sure if it helps but try:
#pragma link C++ class MyClass+;

Hello Wile,

Thanks a lot, the new pragma cmd is really better!
It’s work now !


Hello ! I’m coming back, because I get right now this kind of error.

/afs/ symbol lookup error: /afs/ undefined symbol: _ZN4TH1DC1EPKcS1_idd

It looks like a similar error… :frowning:

When you link your “”, do you add the output of:“root-config --libs”?

I didn’t do it, thanks a lot! Sorry i’m not totally aware with all those necessary commands.
Do you have some documents to learn about linkage and rootcint ?


What’s the linker command line that you use now to build your “”?

For ROOT 5, try to have a look at:

  1. grep -r rootcint ${ROOTSYS}/test
  2. ROOT User’s Guide -> Adding a Class
  3. ROOT User’s Guide -> CINT the C++ Interpreter
  4. root [0] .?