Standalone (ROOT) program with gcc 4.6.3

Dear Rooters,
(using ROOT 5.34.05 on Ubuntu 12.04.02 with gcc 4.6.3)
gcc 4.6.3 uses the ld flag --as-needed by default. This leads to the following trap:
Compiling and linking the att simple program with:

g++ minimal.cpp  `root-config --cflags --ldflags --libs`

works without errors.
Running it with ./a.out and hsimple.root from the tutorials results in:

Warning in <TClass::TClass>: no dictionary for class TH1F is available
*** Break *** segmentation violation

Compiling and linking with:

g++ minimal.cpp  -Wl,-no-as-needed `root-config --cflags --ldflags --libs`

runs fine.
I wonder if “-no-as-needed” should be added to the --ldflags to protect the naive user like me.


PS: This topic might have been discussed in the forum, I was just unable to find it with search:
no-as-needed gives no result even I know it appears in some posts.
minimal.cpp (392 Bytes)

In your “main”, try to add the first line in form:
TApplication a(“a”, 0, 0); // just to make sure that the autoloading of ROOT libraries works

Hi Wile,
yes, this helps.