TApplication oddity

Hola rooterinos

I have already fixed this issue, after following advice in an old post by Le Pew, however it would be nice to know how to link properly, without this workaround.

My system is 14.04 ubuntu, I use the 5.34 root-system .deb available in the repositories. g++ 4.8.2

My code

g++ -o ted ted.cpp root-config --cflags --glibs -lTree && ./ted
Warning in TClass::TClass: no dictionary for class TTree is available
Warning in TClass::TClass: no dictionary for class TBranch is available
Warning in TClass::TClass: no dictionary for class TLeafI is available
Warning in TClass::TClass: no dictionary for class TLeaf is available
Warning in TClass::TClass: no dictionary for class TLeafL is available
Warning in TClass::TClass: no dictionary for class TLeafS is available
Warning in TClass::TClass: no dictionary for class TLeafB is available
Warning in TClass::TClass: no dictionary for class TBranchRef is available

*** Break *** segmentation violation

My code when I include the line
TApplication *dummy=new TApplication(“dummy”,0,0);

… works fine!

Cheers!

Ben
ted.cpp (1.84 KB)

That’s not a “workaround”. That’s the proper way of dealing with “autoloading” of classes/libraries in ROOT.

Hi.

Firstly - thanks for all your support work in the forums, your replies in various posts have helped me more than once.

Secondly - I find that strange. Including TApplication.h, even though it is not directly needed, can link to other necessary libraries. But the need to define an unnecessary object as well is the proper way?

Anyway, if it works, it works - I move on.

Cheers!

You can also try to add “-Wl,–no-as-needed” to your linker command line (search for “–no-as-needed” in “man ld”). But do consider it a “brutal fix” (a.k.a. a “workaround”).
Note however that in this case, in your linker command line, you need to explicitly list all ROOT libraries which your application will ever need (i.e. “autoloading” of ROOT classes/libraries will NOT work).

My first try, as more elegant.

The second way worked.