2011-11-09 85 views
1

全部。我下載了一個簡單的GTK +源代碼,:我應該在哪裏放置gtk.h文件?

#include <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; 
} 

當我運行它,

gcc -o simple simple.c `pkg-config --libs --cflags gtk+-2.0` 
-bash: pkg-config: command not found 
simple.c:1:21: error: gtk/gtk.h: No such file or directory 
simple.c: In function ‘main’: 
simple.c:5: error: ‘GtkWidget’ undeclared (first use in this function) 
simple.c:5: error: (Each undeclared identifier is reported only once 
simple.c:5: error: for each function it appears in.) 
simple.c:5: error: ‘window’ undeclared (first use in this function) 
simple.c:9: error: ‘GTK_WINDOW_TOPLEVEL’ undeclared (first use in this function) 

它告訴我gtk.h丟失。但是我怎麼能得到gtk.h?我如何讓程序運行?謝謝。

回答

2

您需要GTK的頭文件和庫。大多數發行版都會發行。例如,在Debian系統上,它們可作爲包libgtk2.0-dev,所以

apt-get install libgtk2.0-dev 

應該做的伎倆。

2

安裝pkg-config爲了使用它,例如。在Debian上:apt-get install pkg-config

相關問題