作者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