当前位置: 技术问答>linux和unix
如何编译GTK程序
来源: 互联网 发布时间:2015-11-15
本文导语: 写了一个简单的GTK程序 如base.c #include int main( int argc, char *argv[] ) { GtkWidget *window; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_show ...
写了一个简单的GTK程序
如base.c
#include
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;
}
用
#pkg-config gtk+-2.0 --modversion
2.2.1
但是用gcc编译出错
#gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`
base.c:1:21:gtk/gtk.h:没有那个文件或目录
base.c:In Functioin 'main';
base.c:5:'GtkWidget' undeclareed(first use in this function)
base.c:5:(Each undeclared identifier is reported only once
base.c:5:for each function it appears in.)
base.c:5:'window' undeclared(first use in this functioin)
base.c:8:'GTK_WINDOW_TOPLEVEL' undeclared(first use in this function)
我刚安装的RedHat 9.0
如base.c
#include
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;
}
用
#pkg-config gtk+-2.0 --modversion
2.2.1
但是用gcc编译出错
#gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`
base.c:1:21:gtk/gtk.h:没有那个文件或目录
base.c:In Functioin 'main';
base.c:5:'GtkWidget' undeclareed(first use in this function)
base.c:5:(Each undeclared identifier is reported only once
base.c:5:for each function it appears in.)
base.c:5:'window' undeclared(first use in this functioin)
base.c:8:'GTK_WINDOW_TOPLEVEL' undeclared(first use in this function)
我刚安装的RedHat 9.0
|
楼上是正解!
另外,"`",这个符号,是TAB键,楼主注意了!
另外,"`",这个符号,是TAB键,楼主注意了!
|
我以前也遇到同样的问题,结果是因为那个符号弄错了,也就是`pkg-config --cflags --libs gtk+-2.0`这个波浪符号,你检查一下是不是因为这个问题?
|
gcc -o test test.c `pkg-config --cflags --libs gtk+-2.0`