segmentation faults

  • will

    will - 2002-10-03

    I am trying to use PLplot within a c++ program. I use
    the following code to initialize plstream:

    plstream pls;

    pls.env(minX, maxX, minY, maxY, 0, 1);

    pls.poin(NumData, (PLFLT *)&x, (PLFLT *)&y, -1);

    To fill my x and y arrays i used the following source:

    double *x;
    x = new double[10];
    double *y;
    y = new double[10];
    for (int i=1; i<=10; i++)
    x[i] = i;
    y[i] = i;

    If I run the program with this source I just get
    segmentation fault, and no chance to select plotting

    If I change the for loop to:

    for (int i=1; i<=10; i++)
    x[i] = i;
    y[i] = i;
    std::cout << i << std::endl;

    The program prints out numbers 1-10, and then gives me
    a choice of plotting options. I choose xwin and a
    blank 10 x 10 box and labeled axes in red appears. I am
    compiling with the following code:

    g++ -o TestGrp
    -L /usr/local/Tools/plplot/lib -I
    /usr/local/Tools/plplot/include -I /usr/X11R6/include
    -L /usr/X11R6/lib
    -lm -lX11 -lplcxx -lplplot

    Any help on how to get a graph on the screen would be
    much appreciated.  

    • Maurice LeBrun

      Maurice LeBrun - 2002-10-14

      If you provide a compilable test program that illustrates
      the problem I'd be glad to look into it.



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks