我正在尝试构建gtk +源附带的示例gtk +示例。我的需要只是为了一个C程序有一个gtk + UI。我开始下载并构建gtk +,但实现了(通过SO)这不需要,我只需要libgtk-3-dev。
sudo apt-get install libgtk-3-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libgtk-3-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 373 not upgraded.
编辑:注意:问题不在于库的序列或包括因为我使用gtk +附带的makefile。
我尝试使用我下载的gtk +代码编译一个示例。我得到以下错误。关于这个主题的其他查询提到标志的顺序很重要,但在这种情况下,我使用了源附带的makefile。我应该安装比libgtk-3-dev库更多的东西(在Ubuntu 14.04上运行)。
~/gtk/examples/application1$ make -f Makefile.example
cc -c -o main.o -pthread -I / usr / include / gtk-3.0 -I / usr / include / atk-1.0 -I / usr / include / at-spi2-atk / 2.0 -I / usr / include / pango-1.0 -I / usr / include / gio-unix-2.0 / -I / usr / include / cairo -I / usr / include / gdk-pixbuf-2.0 -I / usr / include / glib-2.0 -I / usr / lib / x86_64-linux-gnu / glib-2.0 / include -I / usr / include / harfbuzz -I / usr / include / freetype2 -I / usr / include / pixman-1 -I / usr / include / libpng12 main.c
cc -c -o exampleapp.o -pthread -I / usr / include / gtk-3.0 -I / usr / include / atk-1.0 -I / usr / include / at-spi2-atk / 2.0 -I / usr / include /pango-1.0 -I / usr / include / gio-unix-2.0 / -I / usr / include / cairo -I / usr / include / gdk-pixbuf-2.0 -I / usr / include / glib-2.0 -I / usr / lib / x86_64-linux-gnu / glib-2.0 / include -I / usr / include / harfbuzz -I / usr / include / freetype2 -I / usr / include / pixman-1 -I / usr / include / libpng12 exampleapp 。C
cc -c -o exampleappwin.o -pthread -I / usr / include / gtk-3.0 -I / usr / include / atk-1.0 -I / usr / include / at-spi2-atk / 2.0 -I / usr / include /pango-1.0 -I / usr / include / gio-unix-2.0 / -I / usr / include / cairo -I / usr / include / gdk-pixbuf-2.0 -I / usr / include / glib-2.0 -I / usr / lib / x86_64-linux-gnu / glib-2.0 / include -I / usr / include / harfbuzz -I / usr / include / freetype2 -I / usr / include / pixman-1 -I / usr / include / libpng12 exampleappwin 。C
cc -o exampleapp -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 main.o exampleapp .o exampleappwin.o
main.o:在函数main':
main.c:(.text+0x11): undefined reference to
g_application_get_type'
main.c :(。text + 0x24):对g_type_check_instance_cast'
main.c:(.text+0x35): undefined reference to
g_application_run'的未定义引用
exampleapp.o:在函数example_app_class_intern_init':
exampleapp.c:(.text+0x14): undefined reference to
g_type_class_peek_parent'
exampleapp.c :(。text + 0x36):未定义引用g_type_class_adjust_private_offset'
exampleapp.o: In function
example_app_get_type':
exampleapp.c :(。text + 0x66):对g_once_init_enter'
exampleapp.c:(.text+0x84): undefined reference to
g_intern_static_string'的未定义引用
exampleapp.c :(。text + 0x8c):对gtk_application_get_type'
exampleapp.c:(.text+0xb4): undefined reference to
g_type_register_static_simple'的未定义引用
exampleapp.c :(。text + 0xc9):未定义引用g_once_init_leave'
exampleapp.o: In function
example_app_activate':
exampleapp.c :(。text + 0x104):对g_type_check_instance_cast'
exampleapp.c:(.text+0x115): undefined reference to
gtk_window_get_type'的未定义引用
exampleapp.c :(。text + 0x127):对g_type_check_instance_cast'
exampleapp.c:(.text+0x12f): undefined reference to
gtk_window_present'的未定义引用
exampleapp.o:在函数example_app_open':
exampleapp.c:(.text+0x14d): undefined reference to
gtk_application_get_type'
exampleapp.c :(。text + 0x15f):对g_type_check_instance_cast'
exampleapp.c:(.text+0x167): undefined reference to
gtk_application_get_windows'的未定义引用
exampleapp.c :(。text + 0x18c):对g_type_check_instance_cast'
exampleapp.c:(.text+0x1a9): undefined reference to
g_type_check_instance_cast'的未定义引用
exampleapp.c :(。text + 0x1f5):未定义引用gtk_window_get_type'
exampleapp.c:(.text+0x207): undefined reference to
g_type_check_instance_cast'
exampleapp.c :(。text + 0x20f):未定义引用gtk_window_present'
exampleapp.o: In function
example_app_class_init':
exampleapp.c :(。text + 0x222):对g_application_get_type'
exampleapp.c:(.text+0x234): undefined reference to
g_type_check_class_cast'的未定义引用
exampleapp.c :(。text + 0x244):对g_application_get_type'
exampleapp.c:(.text+0x256): undefined reference to
g_type_check_class_cast'的未定义引用
exampleapp.o:在函数example_app_new':
exampleapp.c:(.text+0x294): undefined reference to
g_object_new'
exampleappwin.o:在函数example_app_window_class_intern_init':
exampleappwin.c:(.text+0x14): undefined reference to
g_type_class_peek_parent'
exampleappwin.c :(。text + 0x36):未定义引用g_type_class_adjust_private_offset'
exampleappwin.o: In function
example_app_window_get_type':
exampleappwin.c :(。text + 0x66):对g_once_init_enter'
exampleappwin.c:(.text+0x84): undefined reference to
g_intern_static_string'的未定义引用
exampleappwin.c :(。text + 0x8c):对gtk_application_window_get_type'
exampleappwin.c:(.text+0xb4): undefined reference to
g_type_register_static_simple'的未定义引用
exampleappwin.c :(。text + 0xc9):未定义引用g_once_init_leave'
exampleappwin.o: In function
example_app_window_new':
exampleappwin.c :(。text + 0x117):对`g_object_new'的未定义引用
collect2:错误:ld返回1退出状态
make:*** [exampleapp]错误1
答案 0 :(得分:1)
无论出于何种原因,GTK + 3.20源代码树中的Makefile都被破坏了;按照n.m。的评论。可能已经有一个错误修正,如果不是修复,那就是。
但是你不能将GTK + 3.20与Ubuntu 14.04 LTS附带的GTK + 3.10一起使用。您最好使用GTK + 3.10示例和源代码。如果你真的想使用更新版本的GTK +,你可以使用jhbuild设置一个独立于系统其他部分的环境(通常在/opt/gnome
中),以构建更新版本的GTK +。