[問題] 請問在mac上使用gtk OTZ

看板MacDev作者 (香蕉公車)時間16年前 (2008/11/26 02:52), 編輯推噓4(407)
留言11則, 6人參與, 最新討論串1/2 (看更多)
小弟我想在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

11/26 02:54, , 1F
pkg-config 會是 linux 專屬的指令嗎?
11/26 02:54, 1F

11/26 02:59, , 2F
不是很了解 @@>??
11/26 02:59, 2F

11/26 03:00, , 3F
我直接gcc helloGtk.c -o helloGtk也不行 OTZ
11/26 03:00, 3F

11/26 10:17, , 4F
你有設定PATH嗎 /opt/usr/bin之類的...
11/26 10:17, 4F

11/26 10:18, , 5F
macport的程式都裝到這裡...
11/26 10:18, 5F

11/26 11:57, , 6F
你沒有指定 header 檔的 search path
11/26 11:57, 6F

11/26 13:27, , 7F
請問要怎麼指定@@>?? 感謝感謝 OTZ
11/26 13:27, 7F

11/26 23:05, , 8F
我的有pkg-config. header可能要指定-I/opt/local/include
11/26 23:05, 8F

11/27 00:41, , 9F
嗯,而且應該是 ` 不是 '
11/27 00:41, 9F

01/02 09:35, , 10F
找一下gtk的.pc擋在哪裡 加到PKG_CONFIG_PATH
01/02 09:35, 10F

01/02 09:36, , 11F
例如/usr/lib/pkgconfig /usr/X11/lib/pkgconfig 之類的
01/02 09:36, 11F
文章代碼(AID): #19B4bnKQ (MacDev)
文章代碼(AID): #19B4bnKQ (MacDev)