C_and_CPP 板


LINE

開發平台(Platform): (Ex: Win10, Linux, ...) Windows 7 + cygwin 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) gcc 6.4.0 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) gtk3.0 問題(Question): 一直無法成功建立GTK的編譯環境,我在安裝介面搜尋GTK 把Devel下的選項全部安裝,也 安裝xinit了 但是在使用gcc編譯時他卻顯示gtk/gtk.h : no such file or directory 使用 pkg-config gtk+-3.0--cflags --libs 則顯示 Package gtk+-3.0--cflags was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-3.0--cflags.pc' to the PKG_CONFIG_PATH environment variable No package 'gtk+-3.0--cflags' found 但使用 pkg-config gtk+-3.0 --libs 則會顯示 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl 預期的正確結果(Expected Output): 正常編譯GTK程式 錯誤結果(Wrong Output): gtk/gtk.h : no such file or directory 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) #include <gtk/gtk.h> //關聯圖形庫 int main(int argc, char* argv[]) { GtkWidget* window; //創建圖形窗口 GtkWidget* label; //創建 gtk_init(&argc, &argv); //初始化圖形驅動 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); //創建圖形頂層畫布 label = gtk_label_new("Hello World."); //創建新的標籤 gtk_container_add(GTK_CONTAINER(window), label); //關聯畫布和標籤 gtk_widget_show_all(window); //顯示驅動程序 gtk_main(); //顯示畫面 return 0; } 補充說明(Supplement): 參考以下教學 http://blog.csdn.net/pjzck/article/details/51205202 --



※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.126.109.77
※ 文章網址: https://webptt.com/m.aspx?n=bbs/C_and_CPP/M.1519847521.A.AD2.html
1F:→ Lipraxde: gtk+-3.0 --cflags,中間有個空白 03/01 06:09
你好,感謝 將編譯參數改為 gcc -Wall hello.c -o Hello `pkg-config gtk+-3.0 --cflags --libs` 便可正常邊譯 但在執行時卻顯示 Gtk-WARNING **: cannot open display: 我猜是Xwindow的參數設定錯誤 但目前還沒有解答(絕讚google中) 如果有解決方法還請幫忙解惑<(_ _)> 話說有沒有辦法不靠Xwindow直接執行的方法(windows下) ※ 編輯: wei115 (101.138.162.172), 03/01/2018 13:46:06
2F:→ Lipraxde: startxwin,那篇文章不是有寫嗎... 03/01 14:15
3F:→ Lipraxde: 乖乖用linux會幫你省很多麻煩 03/01 14:15
用了startwin但沒辦法,執行後左下角出現X的圖示,但右鍵後卻沒教學說的 Terminal選項 至於linux嘛.....圖形模式比windows難QQ 而且我想寫windows的GUI程式. 以下log (II) xorg.conf is not supported (II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information LoadPreferences: /home/weinb/.XWinrc not found LoadPreferences: Loading /etc/X11/system.XWinrc LoadPreferences: Done parsing the configuration file... winDetectSupportedEngines - RemoteSession: no winDetectSupportedEngines - DirectDraw4 installed, allowing ShadowDDNL winDetectSupportedEngines - Returning, supported engines 00000005 winSetEngine - Multi Window or Rootless => ShadowGDI winScreenInit - Using Windows display depth of 32 bits per pixel winAllocateFBShadowGDI - Creating DIB with width: 1366 height: 768 depth: 32 winFinishScreenInitFB - Masks: 00ff0000 0000ff00 000000ff winInitVisualsShadowGDI - Masks 00ff0000 0000ff00 000000ff BPRGB 8 d 24 bpp 32 MIT-SHM extension disabled due to lack of kernel support XFree86-Bigfont extension local-client optimization disabled due to lack of shared memory support in the kernel glWinSelectGLimplementation: Loaded 'cygnativeGLthunk.dll' (II) AIGLX: Testing pixelFormatIndex 1 GL_VERSION: 3.1.0 - Build 9.17.10.4229 GL_VENDOR: Intel GL_RENDERER: Intel(R) HD Graphics 3000 (II) GLX: enabled GLX_SGI_make_current_read (II) GLX: enabled GLX_SGI_swap_control (II) GLX: enabled GLX_MESA_swap_control (II) GLX: enabled GLX_SGIX_pbuffer (II) GLX: enabled GLX_ARB_multisample (II) GLX: enabled GLX_SGIS_multisample (II) GLX: enabled GLX_ARB_fbconfig_float (II) GLX: enabled GLX_EXT_fbconfig_packed_float (II) GLX: enabled GLX_ARB_create_context (II) GLX: enabled GLX_ARB_framebuffer_sRGB (II) AIGLX: enabled GLX_MESA_copy_sub_buffer (II) 60 pixel formats reported by wglGetPixelFormatAttribivARB (II) 24 fbConfigs (II) ignored pixel formats: 0 not OpenGL, 0 unknown pixel type, 36 unaccelerated (II) GLX: Initialized Win32 native WGL GL provider for screen 0 winPointerWarpCursor - Discarding first warp: 683 384 (--) 5 mouse buttons found (--) Setting autorepeat to delay=500, rate=31 (--) Windows keyboard layout: "00000404" (00000404) "Chinese (Traditional) - US Keyboard", type 7 (--) Found matching XKB configuration "Chinese (Traditional)" (--) Model = "pc105" Layout = "cn" Variant = "none" Options = "none" Rules = "base" Model = "pc105" Layout = "cn" Variant = "none" Options = "none" winInitMultiWindowWM - DISPLAY=:0.0 winMultiWindowXMsgProc - DISPLAY=:0.0 cat: '': No such file or directory winInitMultiWindowWM - xcb_connect () returned and successfully opened the display. winProcEstablishConnection - winInitClipboard returned. winClipboardThreadProc - DISPLAY=:0.0 winMultiWindowXMsgProc - xcb_connect() returned and successfully opened the display. Using Composite redirection OS maintains clipboard viewer chain: yes winClipboardProc - XOpenDisplay () returned and successfully opened the display. LoadPreferences: /home/weinb/.XWinrc not found LoadPreferences: Loading /etc/X11/system.XWinrc LoadPreferences: Done parsing the configuration file... SetupSysMenu: GetSystemMenu() failed for HWND 0xe802ce SetupSysMenu: GetSystemMenu() failed for HWND 0xc0764 LoadPreferences: /home/weinb/.XWinrc not found LoadPreferences: Loading /etc/X11/system.XWinrc LoadPreferences: Done parsing the configuration file... SetupSysMenu: GetSystemMenu() failed for HWND 0xe802ce SetupSysMenu: GetSystemMenu() failed for HWND 0xc0764 ※ 編輯: wei115 (120.109.128.225), 03/01/2018 14:34:09
4F:→ Lipraxde: 改用Mingw,或者Qt 03/01 15:19
5F:→ wei115: 好吧QQ 03/01 15:36
6F:→ wei115: 謝謝 03/01 15:36
7F:推 rehon: 改用msys2 這比cygwin好用多了 03/01 20:18
8F:→ rehon: 編譯環境參考 https://wiki.geany.org/howtos/win32/msys2 03/01 20:18
謝謝,改用msys2了,但目前變成設定msys2出問題了....
9F:→ joe820730: 用VcXsrv搭建XWindow,然後term底下輸入: 03/01 23:25
10F:→ joe820730: export DISPLAY=127.0.0.1:0 03/01 23:25
11F:→ joe820730: 不過如果真要弄GTK還是用Linux吧,畢竟GTK生於Linux 03/01 23:30
12F:→ joe820730: 喔等等,你應該看這篇:https://goo.gl/3G9J1L 03/01 23:35
13F:→ joe820730: 用cygwin跑GTK的話會接到Xwindow,直接用MinGW才會直接 03/01 23:36
14F:→ joe820730: 直接使用Windows的視窗 03/01 23:37
恩恩,感謝,回去查了才知道 MinGW的gcc 和 cygwin的gcc 有差別QQ,目前改用MSYS2中
15F:→ uranusjr: GTK 在 Windows 上就是個悲劇, 別自找麻煩 03/02 18:32
為什麼是悲劇阿?
16F:推 xvid: 可以考慮改用 Qt 03/03 20:53
我想用C寫視窗..... ※ 編輯: wei115 (59.126.109.77), 03/03/2018 21:12:16 喔喔,感謝各位大大 終於搞好了,用MSYS2安裝GTK好容易阿阿阿阿(雖然裝MSYS2環境的時候發生不少問題) 話說我終於搞清楚cygwin和MinGW的差別了 以前一直以為MinGW只是把編譯相關的東西從cygwin獨立出來 結果不是,還有一些引用函式庫的不同(cygwin POSIX, MinGW WIN32) 好八,看來可以開始hello, world惹QQ ※ 編輯: wei115 (59.126.109.77), 03/04/2018 03:19:04







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Soft_Job站內搜尋

TOP