Hi Jose, You simply have a scope problem. When you finish execution, your objects created in the stack (all TF1) are automatically deleted. Note that you do not need to write a Makefile to execute the program with the native compiler. ROOT can do it for you automatically in a machine independent way. For example try root > .x jose.C root > .x jose.C++ In the first case, the file jose.C (below) will be executed via the interpreter. In the second case, the file jose.C will be compiled, linked and run via the native compiler. For more details, see the Users Guide (ACLIC). Rene Brun //file jose.C #include "TCanvas.h" #include "TGraph.h" #include "TF1.h" void jose(){ TF1 *f1 = new TF1("fun1","sin(x)/x",0,10); TF1 *f2 = new TF1("fun2","sin(x)/x",-5,5); TF1 *f3 = new TF1("fun3","x^2",0,10); TF1 *f4 = new TF1("fun4","x^2",-5,5); TCanvas *MyC =new TCanvas("MyC","Test Canvas",1); MyC->Divide(2,2); MyC->cd(1); f1->Draw("AC*"); MyC->cd(2); f2->Draw("AC*"); MyC->cd(3); f3->Draw("AC*"); MyC->cd(4); f4->Draw("AC*"); } On Mon, 16 Jul 2001, Emilio Jose Vilchez Martinez wrote: > Hello , > > I am a new Spanish user of root and is the first time I program in C++, > I have done a simple example from root user guide (a canvas that is > divided in four pads) and i add one graph in each one, but while in root > interpreter it works fine, when I try to compile the program with gcc-2.95 > in a linux Mandrake 7.2 including the shared librarys provided with ROOT > it links without any problem but when I execute the program a core dumped > message is returned. > > This the C++ code(prueba.C): > > #include "TCanvas.h" > #include "TGraph.h" > #include "TF1.h" > > > void main(){ > > > TF1 f1("fun1","sin(x)/x",0,10); > TF1 f2("fun2","sin(x)/x",-5,5); > TF1 f3("fun3","x^2",0,10); > TF1 f4("fun4","x^2",-5,5); > TCanvas * MyC =new TCanvas("MyC","Test Canvas",1); > MyC->Divide(2,2); > MyC->cd(1); > f1.Draw("AC*"); > MyC->cd(2); > f2.Draw("AC*"); > MyC->cd(3); > f3.Draw("AC*"); > MyC->cd(4); > f4.Draw("AC*"); > > > } > > this is the makefile: > > > > CC = g++ > LIB=-lCint -lCore -lEG -lGX11 -lGX11TTF -lGpad -lGraf -lGraf3d -lGui -lHist -lHistPainter -lHtml -lMatrix -lMinuit -lNew -lPhysics -lPostscript -lProof -lRGL -lRint -lThread -lTree -lTreePlayer -lTreeViewer -lX3d > > EXEC = prueba > I = /home/emilio/root/include > > $(EXEC) : prueba.o > $(CC) -I$(I) $(LIB) -o $(EXEC) prueba.o > prueba.o : prueba.C > $(CC) -I$(I) -c prueba.C > > > Is obvious that I am a new C++ user on unix seing the code of the makefile > i have always programmed on windows platform with visual or borland C++ > but one day I thought why not unix, why not free... > > The last question, is possible to run root on Mandrake 8.0 and there are > some advantages respect 7.2 version. > > Thanks >
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:52 MET