Compile TDatabasePDG

Why I can’t link this?

g++ -o final_macro -pthread -m64 -I/gpfs/storage_4/users/home/proof/root/include  -L/gpfs/storage_4/users/home/proof/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic  final_macro.o

final_macro.o: In function `__static_initialization_and_destruction_0(int, int)':
final_macro.C:(.text+0x108): undefined reference to `TDatabasePDG::TDatabasePDG()'
final_macro.C:(.text+0x116): undefined reference to `TDatabasePDG::GetParticle(char const*) const'
final_macro.C:(.text+0x13f): undefined reference to `TDatabasePDG::~TDatabasePDG()'
final_macro.C:(.text+0x192): undefined reference to `TDatabasePDG::~TDatabasePDG()'
collect2: ld returned 1 exit status

my code starts so:

const double Zmass = TDatabasePDG().GetParticle("Z0")->Mass() * 1000;

The -L path comes from root-config.

What if you try this?

-lEG was added.

[quote=“tpochep”]What if you try this?

-lEG was added.[/quote]

thanks, it works


I just ran into the same compilation problem with TDatabasePDG now with ROOT 5.28, however I’m compiling using root-config --libs

Could you explain why this doesn’t pick up the needed library to link to TDatabasePDG ?

This is what I get from root-config --libs:
-L/Applications/root_64/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -Wl,-rpath,/Applications/root_64/lib -lm -ldl


Hi Heather,

“root-config --libs” intentionally only list a small sub-set of the ROOT library and included only the most used libraries. Thus for less used library (like libEG) you need to explicitly request them (-lEG).