This is working example. See comments how to compile (file name root.cpp, standard executable will have name a.out).
/*
NB: inverse quotes ``!
g++ $ROOTSYS/bin/root-config --cflags --glibs
root.cpp
To build dictionaries see, e.g. xmltree.cpp. I compiled it using
rootcint -f xmltree_dict.cxx -c xmltree.h xmltree_linkdef.h
g++ $ROOTSYS/bin/root-config --cflags --glibs
-o xmltree xmltree.cpp xmltree_dict.cxx
See details about dictionaries in ROOT User Guide,
chapter “Writing a Graphical User Interface”, part “A Standalone Example”
*/
#include <TRint.h> // the only include you need
//#include <TROOT.h> // uncomment to use global variables like gPad, etc.
#include
#include
#include <TH1.h>
#include <TCanvas.h>
using std::cout; using std::endl;
main(int argc, char argv[])
{
TRint theApp = new TRint(“Rint”, &argc, argv, 0, 0, 1); // do not show splash screen
// code starts here
TH1F* h = new TH1F(“h”, “h”, 100, -3, 3);
h->FillRandom(“gaus”, 10000);
cout<< "h->GetMean() = " << h->GetMean() << " h->GetRMS() = " << h->GetRMS() <<endl;
new TCanvas();
h->Draw();
// work in command line mode
theApp->Run();
delete theApp;
}