Problem with TCanvas

Hello,

I got a problem with TCanvas.
I write a program with a makefile, I compile it with no issue.
But when i launch it, there are non graphical output.

I use the following makefile :

[code]CXXFLAGS := -g -Wall
CXX = g++

ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs) -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lTreePlayer -lMLP -lMinuit -lHtml -lThread

CXXFLAGS += $(ROOTCFLAGS)

LIBS = $(ROOTLIBS) $(SYSLIBS)

SRC = $(wildcard *.cpp)
OBJ = $(SRC:.cpp=.o)
EXE = main

all : $(EXE)

$(EXE):$(OBJ)
$(CXX) ${LIBS} -o $(EXE) $(OBJ)

%.o : %.cpp
@echo "-> Building object : " $@
@$(CXX) $(CXXFLAGS) -fPIC -o $@ -c $<

clean :
@rm -f *.o
@rm -f main[/code]

and the part of my program who don’t work is :

[code]//includes

#include “Drift.h”

using namespace std;

int main(int argc,char** argv)
{
//////Code for filling my class

TH2D *hTraceXZ = new TH2D ("h" , "SRIMXZ", (Int_t)NbStripX,(Double_t) 0.0 ,(Double_t)NbStripX ,(Int_t)NbImages ,(Double_t)0. ,(Double_t)NbImages );



for(int i = 0 ; i < (MyClass->GetTraceXZ()).size() ; i++)
{
	for (unsigned int j = 0; j < ((MyClass->GetTraceXZ()).at(i)).size(); j ++)
	{
		hTraceXZ->Fill((MyClass->GetTraceXZ())[i][j],j);
		cout<<"pouf1 "<<(MyClass->GetTraceXZ())[i][j]<<endl;
	}
	
	
}

TCanvas *c1 = new TCanvas("c1","c1");

cout<<hTraceXZ->GetEntries()<<endl;

hTraceXZ->Draw("");


return 0;

}[/code]

Please help. Thanks

Almost immediately after you create your canvas, your main finishes (i.e. “return 0;”) which then closes your canvas.
Maybe, just before the “return 0;”, put something like:
c1->SaveAs(“c1.eps”);

It’s work, thanks.
Are there a mean to stop the program ?
And wait an action from the user ?

edit :

I fond a mean for stop the program and wait. But nothing happen ?!?!?!

[code]// dummy.cxx

#include “TApplication.h”
#include “TSystem.h”
#include “TCanvas.h”
#include “TH1.h”

#include <unistd.h>

int main(int argc, char **argv)
{
TApplication theApp(“App”, &argc, argv);

TCanvas *c1 = new TCanvas(“c1”,“c1”);
gSystem->ProcessEvents();

TH1F *h = new TH1F(“h”, “h”, 100, 0, 1);

h->Draw();

c1->Modified();
c1->Update();
gSystem->ProcessEvents();

sleep(5);

return 0;
}[/code]

`root-config --cxx --cflags` -o dummy dummy.cxx `root-config --glibs` ./dummy

It’s work !! Thanks.
But I can modify the scale of my plot.
Are there a mean ?