+ -
当前位置:首页 → 问答吧 → [问题]请问如何编译gtk的程式??

[问题]请问如何编译gtk的程式??

时间:2004-01-12

来源:互联网

debian unstable
gcc base.c -o base 'pkg-config --cflags --libs gtk+-2.0'

它出现
gcc: pkg-config --cflags --libs gtk+-2.0: 没有此一档案或目录
base.c:1:21: gtk/gtk.h: 没有此一档案或目录
base.c: In function `main':
base.c:5: error: `GtkWidget' undeclared (first use in this function)
base.c:5: error: (Each undeclared identifier is reported only once
base.c:5: error: for each function it appears in.)
base.c:5: error: `window' undeclared (first use in this function)
base.c:9: error: `GTK_WINDOW_TOPLEVEL' undeclared (first use in this function)

不过gtk.h有在/usr/include/gtk-2.0/gtk/里面
请问应该要怎么设定才对??

作者: jengwei   发布时间: 2004-01-12

`pkg-config --cflags --libs gtk+-2.0`是用来产生像代码: 选择全部-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
这一串东西的,但是你的gcc好像把他当成了单纯的参数
jengwei 写:gcc: pkg-config --cflags --libs gtk+-2.0: 没有此一档案或目录
那当然回找不到gtk.h了
所以要先确定你`pkg-config --cflags --libs gtk+-2.0`的结果是对的

作者: kanru   发布时间: 2004-01-12

档头用这个试试看#include <usr/include/gtk-2.0/gtk/gtk.h>

作者: 209088970   发布时间: 2004-01-12

这里有简易的教学
http://debian.linux.org.tw/~kevpeng/

作者: huki   发布时间: 2004-01-12

I think this is apparently a common typo for beginners:

Please use backquote mark ` instead of single quotation mark ' around your pkg-config command.

作者: 高原之狼   发布时间: 2004-01-13

jengwei 写:debian unstable
gcc base.c -o base 'pkg-config --cflags --libs gtk+-2.0'

它出现
gcc: pkg-config --cflags --libs gtk+-2.0: 没有此一档案或目录
base.c:1:21: gtk/gtk.h: 没有此一档案或目录
base.c: In function `main':
base.c:5: error: `GtkWidget' undeclared (first use in this function)
base.c:5: error: (Each undeclared identifier is reported only once
base.c:5: error: for each function it appears in.)
base.c:5: error: `window' undeclared (first use in this function)
base.c:9: error: `GTK_WINDOW_TOPLEVEL' undeclared (first use in this function)

不过gtk.h有在/usr/include/gtk-2.0/gtk/里面
请问应该要怎么设定才对??


因为你可能输入的上引号不正确

错误:
gcc base.c -o base 'pkg-config --cflags --libs gtk+-2.0'

正确:
gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`

作者: achigo   发布时间: 2009-05-18

Here is all Gtk build motheds and debug fast way

http://www.wretch.cc/blog/fatalfeel

作者:   发布时间: 2010-07-27