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/cn.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灯, 水草

请输入看板名称,例如:iOS站内搜寻

TOP