首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用gtk+-3.0编写程序?

如何用gtk+-3.0编写程序?
EN

Stack Overflow用户
提问于 2015-08-07 16:40:13
回答 2查看 1.8K关注 0票数 0

我使用的是ubuntu 12.04中的GTK+-3.0。我试着编译程序,但每次都失败了

代码语言:javascript
复制
apple@ubuntu:~/Downloads$ gcc -Wall -g gtktest.c $(pkg-config --libs --cflags gtk+-3.0) -o gtktest

gtktest.c: In function ‘main’:
gtktest.c:21:3: warning: implicit declaration of function ‘gtk_signal_connect’ [-Wimplicit-function-declaration]
gtktest.c:21:3: warning: implicit declaration of function ‘GTK_OBJECT’ [-Wimplicit-function-declaration]
gtktest.c:21:3: warning: implicit declaration of function ‘GTK_SIGNAL_FUNC’ [-Wimplicit-function-declaration]
gtktest.c:22:3: warning: implicit declaration of function ‘gtk_container_border_width’ [-Wimplicit-function-declaration]
gtktest.c:28:3: warning: implicit declaration of function ‘gtk_signal_connect_object’ [-Wimplicit-function-declaration]
/tmp/ccH48jvQ.o: In function `main':
/home/apple/Downloads/gtktest.c:21: undefined reference to `GTK_SIGNAL_FUNC'
/home/apple/Downloads/gtktest.c:21: undefined reference to `GTK_OBJECT'
/home/apple/Downloads/gtktest.c:21: undefined reference to `gtk_signal_connect'
/home/apple/Downloads/gtktest.c:22: undefined reference to `gtk_container_border_width'
/home/apple/Downloads/gtktest.c:26: undefined reference to `GTK_SIGNAL_FUNC'
/home/apple/Downloads/gtktest.c:26: undefined reference to `GTK_OBJECT'
/home/apple/Downloads/gtktest.c:26: undefined reference to `gtk_signal_connect'
/home/apple/Downloads/gtktest.c:28: undefined reference to `GTK_OBJECT'
/home/apple/Downloads/gtktest.c:28: undefined reference to `GTK_SIGNAL_FUNC'
/home/apple/Downloads/gtktest.c:28: undefined reference to `GTK_OBJECT'
/home/apple/Downloads/gtktest.c:28: undefined reference to `gtk_signal_connect_object'
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_lookup'
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_insert'
/usr/local/lib/libcairo.so: undefined reference to `pixman_composite_glyphs'
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_remove'
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_get_mask_format'
/usr/local/lib/libcairo.so: undefined reference to `pixman_composite_glyphs_no_mask'
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_thaw'
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_freeze'
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_create'
collect2: ld returned 1 exit status

使用另一个命令。

代码语言:javascript
复制
apple@ubuntu:~/Downloads$ gcc -Wall -g gtktest.c $(pkg-config --libs --cflags glib-2.0) -o gtktest
        In file included from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:30:0,
                         from /usr/include/gtk-3.0/gdk/gdk.h:32,
                         from /usr/local/include/gtk-3.0/gtk/gtk.h:32,
                         from gtktest.c:1:
        /usr/include/gtk-3.0/gdk/gdktypes.h:37:19: fatal error: cairo.h: No such file or directory
        compilation terminated.

任何人如何解决这个问题我在过去的4天里一直在努力解决这个问题。有没有人能给我一个合适的解决方案?

EN

回答 2

Stack Overflow用户

发布于 2015-08-08 02:08:22

代码语言:javascript
复制
gtktest.c:21:3: warning: implicit declaration of function ‘gtk_signal_connect’

您正在编译的代码是为一个非常旧的GTK+版本编写的。如果你想要用GTK+3编译代码,你必须修改代码,更不用说用GTK+2编译了,几乎可以肯定的是,开始使用have会更容易。

代码语言:javascript
复制
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_lookup'

我猜你的cairo版本期望的是一个比你链接的版本更新的小精灵:例如,pixman_glyph_cache_lookup()是在小精灵0.27.2中添加的。

最后一个示例尝试在没有GTK include标志的情况下编译GTK代码:这是行不通的。

票数 3
EN

Stack Overflow用户

发布于 2015-08-07 17:47:34

使用

配置或$(pkg- -lcairo --libs --c cairo)

和-lpixman或-lpixman-1

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31873262

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档