I am trying to embed a plplot program inside a window using gtk, my first attempt was unsuccessful. I tried with a little example coda at the plplot documentation page.

#include <plplotcanvas.h>
    #include <libgnomecanvas/libgnomecanvas.h>
    #include <gtk/gtk.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <plplot.h>

    /* The width and height of the plplot canvas widget */
    #define WIDTH 1000 /* 500 */
    #define HEIGHT 600 /* 300 */

    /* Delete event callback */
    gint delete_event( GtkWidget *widget,GdkEvent *event,gpointer data ) {
    return FALSE;

    /* Destroy event calback */
    void destroy(GtkWidget *widget,gpointer data) {
    gtk_main_quit ();

    int main(int argc,char *argv[] )

    PlplotCanvas* canvas;
    GtkWidget *window;

    /* Parse the options */
    plparseopts(&argc, argv, PL_PARSE_FULL);

    /* The data to plot */
    double x[11] = {0,1,2,3,4,5,6,7,8,9,10};
    double y[11] = {0,0.1,0.4,0.9,1.6,2.6,3.6,4.9,6.4,8.1,10};

    /* Initialize gtk and the glib type system */
    gtk_init(&argc, &argv);

    /* Create the canvas and set its size; during the creation process,
    * the gcw driver is loaded into plplot, and plinit() is invoked.

    /* Create a new window and stuff the canvas into it */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    /* Connect the signal handlers to the window decorations */

    /* Display everything */

    /* Draw on the canvas with Plplot */
    plplot_canvas_pladv(canvas,0); /* Advance to first page */
    plplot_canvas_plcol0(canvas,15); /* Set color to black */
    plplot_canvas_plwid(canvas,2); /* Set the pen width */
    plplot_canvas_plvsta(canvas); /* Set the viewport */
    plplot_canvas_plwind(canvas,0.,10.,0.,10.); /* Set the window */
    plplot_canvas_plbox(canvas,"bcnst",0.,0,"bcnstv",0.,0); /* Set the box */
    plplot_canvas_pllab(canvas,"x-axis","y-axis","A Simple Plot"); /* Draw some labels */

    /* Draw the line */
    plplot_canvas_plcol0(canvas,1); /* Set the pen color */

    /* Advancing the page finalizes this plot */

    /* Start the gtk main loop */


gcc `pkg-config --cflags --libs plplotd gtk+-2.0` plem.c -o plem

i get the next error:

In file included from plem.c:1:
In file included from /usr/local/Cellar/plplot/5.10.0/include/plplot/plplotcanvas.h:33:
/usr/local/Cellar/plplot/5.10.0/include/plplot/gcw.h:38:10: fatal error: 'libgnomecanvas/libgnomecanvas.h' file not found 

I found the libgnomecanvas using:

find / -name "libgnomecanvas.h"

The file is at:


I changed the include to


Then i get more errors because libgnomecanvas.h can not locate the libraries at the same folder. I tried to change all the includes and the same error again and again (maybe it was the wrong approach… a little dumb i think). Then i tried to use the compile instructions at the manual:http://archive.tcltk.co.kr/doc/plplot-html-5.9.4/gui.html

I compile with this:

gcc plem.c -o plem `PKG_CONFIG_PATH=/usr/local/lib/pkgconfig pkg-config --cflags --libs plplotd-gnome2`

Then i get:

Package plplotd-gnome2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `plplotd-gnome2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'plplotd-gnome2' found
plem.c:1:11: fatal error: 'plplotcanvas.h' file not found
        #include <plplotcanvas.h>

So i try to find plplotd-gnome2.pc but i have not success at all (not installed). Then back to my files i found the pkgconfig file of libgnocanvas and i execute export pgkconfig and again the same error a new one. I am a little bit confused right now :S. Any idea about what is happening here and how i can fix it?. Thanks in advance guys and have a nice day!

PS: anyone know any other example of use between gtk and plplot? i found some cairo mentions but cairo only shows 2D graphs and maybe i will need 3D capabilities at the near future :).