Compiling C ++ / GTK in Eclipse

I am working on a version of Eclipse in C / C ++ to create a simple GTK application. However, I cannot compile a GTK sample from Eclipse.

I think gtk is installed correctly, using ubuntu package manager.

the code:

#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 followed the instructions here to configure the command line patterns"pkg-config --cflags --libs gtk+-2.0"

but I get the following errors:

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

A little disappointed, any help is much appreciated

+3
source share
2 answers

You forgot the back quotes.

Change the end of the command line to

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

This means "take the command output between backquotes and replace it with your result."

+2
source

libgtk2.0-dev. gtk+-2.0/gtk/gtk.h gtk/gtk.h, ( klez) :

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

Source: https://habr.com/ru/post/1759166/


All Articles