我使用的是ubuntu 12.04中的GTK+-3.0。我试着编译程序,但每次都失败了
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使用另一个命令。
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天里一直在努力解决这个问题。有没有人能给我一个合适的解决方案?
发布于 2015-08-08 02:08:22
gtktest.c:21:3: warning: implicit declaration of function ‘gtk_signal_connect’您正在编译的代码是为一个非常旧的GTK+版本编写的。如果你想要用GTK+3编译代码,你必须修改代码,更不用说用GTK+2编译了,几乎可以肯定的是,开始使用have会更容易。
/usr/local/lib/libcairo.so: undefined reference to `pixman_glyph_cache_lookup'我猜你的cairo版本期望的是一个比你链接的版本更新的小精灵:例如,pixman_glyph_cache_lookup()是在小精灵0.27.2中添加的。
最后一个示例尝试在没有GTK include标志的情况下编译GTK代码:这是行不通的。
发布于 2015-08-07 17:47:34
使用
配置或$(pkg- -lcairo --libs --c cairo)
和-lpixman或-lpixman-1
https://stackoverflow.com/questions/31873262
复制相似问题