作者operationcow (香蕉公车)
看板MacDev
标题[问题] 请问在mac上使用gtk OTZ
时间Wed Nov 26 02:52:32 2008
小弟我想在macbook上写gtk的程式
於是利用macport
sudo port install gtk2
萤幕显示了
Skipping org.macports.activate (gtk2 +x11) since this port is already active
---> Cleaning gtk2
似乎是说我已经安装好了
接着我参考了这个网站
http://caterpillar.onlyfun.net/Gossip/GTKGossip/FirstGTK.html
编译了以下的程式码
//helloGtk.c
#include <gtk/gtk.h>
int main(int argc, char *argv[]) {
GtkWidget *window;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "哈罗!GTK+!");
gtk_widget_show(window);
gtk_main();
return 0;
}
编译的指令如下:
$gcc helloGtk.c -o helloGtk 'pkg-config --cflags --libs gtk+-2.0'
他给我如下的讯息:
i686-apple-darwin9-gcc-4.0.1: pkg-config --cflags --libs gtk+-2.0: No such
file or directory
helloGtk.c:1:21: error: gtk/gtk.h: No such file or directory
helloGtk.c: In function ‘main’:
helloGtk.c:4: error: ‘GtkWidget’ undeclared (first use in this function)
helloGtk.c:4: error: (Each undeclared identifier is reported only once
helloGtk.c:4: error: for each function it appears in.)
helloGtk.c:4: error: ‘window’ undeclared (first use in this function)
helloGtk.c:7: error: ‘GTK_WINDOW_TOPLEVEL’ undeclared (first use in this
function)
小弟是新手,不知道有没有哪位大大教我怎麽在mac上安装gtk及编译gtk程式
感谢感谢 <(__)>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.243.43
1F:推 ducksteven:pkg-config 会是 linux 专属的指令吗? 11/26 02:54
2F:→ operationcow:不是很了解 @@>?? 11/26 02:59
3F:→ operationcow:我直接gcc helloGtk.c -o helloGtk也不行 OTZ 11/26 03:00
4F:推 jlovet:你有设定PATH吗 /opt/usr/bin之类的... 11/26 10:17
5F:→ jlovet:macport的程式都装到这里... 11/26 10:18
6F:→ yllan:你没有指定 header 档的 search path 11/26 11:57
7F:→ operationcow:请问要怎麽指定@@>?? 感谢感谢 OTZ 11/26 13:27
8F:推 jclin:我的有pkg-config. header可能要指定-I/opt/local/include 11/26 23:05
9F:→ yllan:嗯,而且应该是 ` 不是 ' 11/27 00:41
10F:推 bizkit:找一下gtk的.pc挡在哪里 加到PKG_CONFIG_PATH 01/02 09:35
11F:→ bizkit:例如/usr/lib/pkgconfig /usr/X11/lib/pkgconfig 之类的 01/02 09:36