views:

54

answers:

2

I'm fiddling around with the C/C++ version of Eclipse to build a simple GTK app. However, I can't seem to be able to compile a GTK sample from within Eclipse.

I think gtk is installed properly, used the ubuntu Package manager.

the code is:

#include <gtk-2.0/gtk/gtk.h>

int main( int argc, char *argv[] )
{
    GtkWidget *window;

    gtk_init (&argc, &argv);

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show  (window);

    gtk_main ();

    return 0;
}

and I have followed the instructions here to set up the Command line patterns "pkg-config --cflags --libs gtk+-2.0"

but I get these error:

Building file: ../src/GTKtestC.c
Invoking: GCC C Compiler
gcc -I/usr/include/gtk-2.0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/GTKtestC.d" -MT"src/GTKtestC.d" -o"src/GTKtestC.o" "../src/GTKtestC.c" pkg-config --cflags --libs gtk+-2.0
gcc: pkg-config: No such file or directory
gcc: gtk+-2.0: No such file or directory
cc1: error: unrecognized command line option "-fcflags"
cc1: error: unrecognized command line option "-flibs"
make: *** [src/GTKtestC.o] Error 1

Getting a little frustrated, any help much appreciated

+1  A: 

You forgot the backquotes.

Change the end of the command line to

`pkg-config --cflags --libs gtk+-2.0`

This means "take the output of the command between backquotes and replace this with its result".

klez
A: 

Try installing libgtk2.0-dev. Then change the gtk+-2.0/gtk/gtk.h to gtk/gtk.h, and (as klez said) change the end of the command line to:

`pkg-config --cflags --libs gtk+-2.0`
Joe D