Linking root to my code

Hi,

So I was writing my simple code under xcode 3.1 trying to link root dylib as following:

  1. first here is my simple code:
    #include “/sw2/include/root/TH1.h”
    #include “/sw2/include/root/TCanvas.h”

int main () {
TCanvas *c1 = new TCanvas(“c1”,“Example”,10,10,700,500);
c1->SetFillColor(33);
c1->SetFrameFillColor(41);
c1->SetGrid();

TH1F* h = new TH1F("h1","h1 title",100,0,10); 
for (int i=0; i<10; i++){
	h->Fill(i);
}
h->Draw();
return 0;

}

  1. I added libCore.5.20.dylib, libPad.5.20.dylib and libHist.5.20.dylib to my target for linking.

  2. I compile and everything is fine.

  3. I run the program and it returns 0. I also check the value of c1 and h and they are not NULL.

  4. But where is my plot?

Thanks,
Bahman.

Hi,

By default the system is in batch mode.
You need to create a TApplication object
Add

#include “TApplication.h”

and

TApplication *theApp = new TApplication(“myapp”,argc,argv);

Cheers,
Philippe.

Yeah yeah… I can’t believe what I see. Thanks. By the way one need theApp.Run() at the end.