ROOT HISTOGRAMS under g++

Hello,
I would like to plot histograms under g++ compiled program, do anybody know some simple example which I can follow? I have already linked all libraries but the histogram is still not shown in canvas window.
Thank you for your help

I have this function

void SimProc::zDistribution()
{
TCanvas *c1 = new TCanvas(“c1”,“Histogram”,10,10,1200,800);
TH1D *hist1D = new TH1D (“1Dhistogram”,“Distribution of deposited energy in z-axis”,200,-(g.WorldSizeZ/2.), g.WorldSizeZ/2.);
c1->SetFillColor(42);
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(6);
c1->GetFrame()->SetBorderMode(-1);
for(int i=0; i<sim.numberOfEvents; i++) {
cout<<“Sem tu”<loadEvent();
cout<<“Event “<< i <<” loaded”<<endl;
for (int j=0; jFill(h[j].depEnergy, h[j].x);
}

hist1D->Draw();
c1->Modified();
c1->Update();
}

and I have already initial TApplication e.t.c. in main func.