Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling C++/GTK within Eclipse

Tags:

gcc

eclipse

gtk

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

like image 462
Ben Avatar asked Feb 24 '26 22:02

Ben


1 Answers

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".

like image 92
Federico klez Culloca Avatar answered Mar 01 '26 21:03

Federico klez Culloca



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!