[ROOT] Re: segmentation fault with pointer notation

From: Jiri Masik (masik@pc203b.fzu.cz)
Date: Wed Oct 10 2001 - 15:29:53 MEST


Stefan.Funk@cern.ch (Stefan Funk) writes:

> Dear root-users,
> I am having a problem to find out how to compile a standalone
> C++-Programe using root libraries.
> I am using the following syntax and get a segmentation fault. It seems
> to be due to the line
> 
> gr1->Draw("AC*");
> 
> or any other line using this pointer notation. When I comment out this
> line root prints a canvas and has no problems.
> I compile this little programme with:
> g++ -g -O2 -Wall `root-config --cflags --glibs` foo.c -o foo
> 
> Thanks in advance for your help
> 
> #ifndef __CINT__
> 
> #include "/usr/local/root/include/TCanvas.h"
> #include "/usr/local/root/include/TF1.h"
> #include "/usr/local/root/include/TH1.h"
> #include "/usr/local/root/include/TApplication.h"
> #include "/usr/local/root/graf/inc/TGraph.h"
> #include "/usr/local/root/graf/src/TGraph.cxx"
> 
> #endif
> 
> void sinusgraph(void){
>   
>   Int_t n = 20;
>   Double_t x[20], y[20];
>   TGraph *gr1;
>   TCanvas *c1;
>   
>   for (Int_t i=0; i<n; i++){
>     x[i] = i*0.1;
>     y[i] = 10*sin(x[i]+0.2);
>   }
> 
>   gr1 = new TGraph(n,x,y);
>   c1 = new TCanvas("c1", "Graph Draw Options", 200, 10, 600, 400);
>   
>   gr1->Draw("AC*");
> 
> }
> 
> #ifndef __CINT__ 
>   int main(int argc, char** argv) 
>   {
>     TApplication fooApp("fooApp", &argc, argv); 
>      
>     sinusgraph(); 
>  
>     fooApp.Run();
> 
>     return 0;
>   }
> #endif

Hi Stefan,

I cannot reproduce it with the current CVS version on Linux/PPC. I
suggest that you remove this line
> #include "/usr/local/root/graf/src/TGraph.cxx"
and rewrite the includes 
> #include "/usr/local/root/include/TCanvas.h"
#include <TCanvas.h>
to be sure that everything comes from the same installation.

The roottalk-USENET gateway is not bidirectional - send mails to
roottalk@root.cern.ch to reach the list. Don't forget to include Root
version and architecture info.
cheers,
        Jiri



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:02 MET