ROOT GUI functions from C++ code in Mac OS X - crash

I have installed ROOT 5.32 in my computer with Mac OS X 10.6.8. I should anticipate that I have just begun to study ROOT, so there may be something basic that I have not understood.

My assumption was that it should be possible to call any ROOT function, even those that display a graphical output, from C++ code compiled and linked to the root libraries. However, when I attempt to call the Draw() method from any class I see only this Terminal output and nothing other happens:

Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1

Moreover, if I just initialize a TBrowser the program outputs a weird bunch of lines that announces a crash. I am attaching my code and the output I see.

My program:

#include <TBrowser.h>
int main() {
 TBrowser b;
}

The command I use to compile it:

The error it prints:

*** Break *** segmentation violation



===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================

Thread 1 (process 30570):
#0  0x00007fff83f54b28 in wait4 ()
#1  0x00007fff83f690e6 in system ()
#2  0x00000001008ed16c in TUnixSystem::StackTrace ()
#3  0x00000001008ea161 in TUnixSystem::DispatchSignals ()
#4  <signal handler called>
#5  0x00000001008365c7 in TApplication::InitializeGraphics ()
#6  0x000000010083f4e5 in TBrowser::TBrowser ()
#7  0x0000000100001b68 in main ()
===========================================================


The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5  0x00000001008365c7 in TApplication::InitializeGraphics ()
#6  0x000000010083f4e5 in TBrowser::TBrowser ()
#7  0x0000000100001b68 in main ()
===========================================================

Thanks in advance for any advice

If you want to use ROOT’s GUI in a standalone application, you can have a look into how this is usually done in $ROOTSYS/tutorials/gui (though, most of examples are macros here) and in $ROOTSYS/test/RootShower.

Your minimal program should at least create TApplication and start event loop (or your main exits immediately and there is no reason in TBrowser definition).
Try this, for example.

#include <TApplication.h>
#include <TBrowser.h>

int main(int argc, char ** argv)
{
   TApplication app("test_app", &argc, argv);
   TBrowser *b = new TBrowser;
   app.Run();
}

Thank you! Now it works perfectly…

I think someone should write a good manual for ROOT, though… it would be possible to learn much more without deciphering the examples

[quote=“Fiat Lux”]Thank you! Now it works perfectly…

I think someone should write a good manual for ROOT, though… it would be possible to learn much more without deciphering the examples[/quote]

In this case, you’ll have to decipher documentation and examples in documentation:

root.cern.ch/download/doc/25WritingGUI.pdf