2016-05-14 57 views
1

我正在尝试构建一些gtk +源代码随附的示例gtk +示例。我的需要只是为C程序提供gtk + UI。我开始下载和构建gtk +,但是意识到(通过SO),这是不需要的,我只需要libgtk-3-dev。无法构建示例gtk +程序

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 +随附的生成文件。

我试着编译一个我用下载的gtk +代码的例子。我得到下面的错误。关于这个主题的其他查询提到了标志的顺序,但在这种情况下,我使用了随源提供的makefile。我应该安装比libgtk-3-dev库(在Ubuntu 14.04上运行)更多的东西。

~/gtk/examples/application1$ make -f Makefile.example 

立方厘米-c -o main.o -pthread -I的/ usr /包括/ GTK-3.0 -I的/ usr /包括/ ATK-1.0 -I的/ usr /包括/ 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 m​​ain.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/freetype2 -I/usr/include/freetype2 usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz- 1 -I/usr/include/li bpng12 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中:(文本+ 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_pee k_parent” exampleapp.c :(文本+ 0x36):未定义参照g_type_class_adjust_private_offset' exampleapp.o: In function example_app_get_type ': exampleapp.c :(文本+ 0x66):未定义参照g_once_init_enter' exampleapp.c:(.text+0x84): undefined reference to g_intern_static_string' exampleapp.c :(文本+ 0x8c) :未定义参照gtk_application_get_type' exampleapp.c:(.text+0xb4): undefined reference to g_type_register_static_simple” exampleapp.c :(文本+ 0xc9):未定义参照g_once_init_leave' exampleapp.o: In function example_app_activate ': exampleapp.c :(文本+量0x104):未定义参照g_type_check_instance_cast' exampleapp.c:(.text+0x115): undefined reference to gtk_window_get_type' exampleapp.c :(.text + 0x127):undefined reference to g_type_check_instance_cast' exampleapp.c:(.text+0x12f): undefined reference to gtk_window_present' exampleapp.o:In function 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 :(文本+ 0x18c):未定义参照g_type_check_instance_cast' exampleapp.c:(.text+0x1a9): undefined reference to g_type_check_instance_cast ' exampleapp.c :(文本+ 0x1f5):未定义参照gtk_window_get_type' exampleapp.c:(.text+0x207): undefined reference to g_type_check_instance_cast' exampleapp.c :(文本。 + 0x20f):未定义参照gtk_window_present' exampleapp.o: In function example_app_class_init ': exampleapp.c :(文本+ 0x222):未定义参照g_application_get_type' exampleapp.c:(.text+0x234): undefined reference to g_type_check_class_cast' exampleapp.c :(文本+ 0x244):未定义参照g_application_get_type' exampleapp.c:(.text+0x256): undefined reference to g_type_check_class_cast” ExampleApp中。○:在功能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 :(文本+ 0x36):未定义参照g_type_class_adjust_private_offset' exampleappwin.o: In function example_app_window_get_type': exampleappwin.c :(文本+ 0x66):未定义参考到g_once_init_enter' exampleappwin.c:(.text+0x84): undefined reference to g_intern_static_string ' exampleappwin.c :(文本+ 0x8c):未定义参照gtk_application_window_get_type' exampleappwin.c:(.text+0xb4): undefined reference to g_type_register_static_simple'。 exampleappwin.c :(文本+ 0xc9):未定义参照g_once_init_leave' exampleappwin.o: In function example_app_window_new': exampleappwin.c :(文本+ 0x117):未定义引用'g_object_new' collect2:错误:ld返回1退出状态 make:*** [exampleapp]错误1

+1

Ubuntu 14.04只附带GTK + 3.10;您将无法使用它为新版GTK +构建示例。获取GTK + 3.10源代码的一个版本,并且应该构建这些示例。 – andlabs

+0

[为什么库链接的顺序有时会导致GCC错误?](http://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are- linked-sometimes-cause-errors-in-gcc)TL; DR将'main.o'移到所有'-lxxx'前面。 –

+0

@ n.m。他们正在尝试构建一个GTK +源代码的例子,而不是他们自己的程序。这些示例已经有了正确的makefile。如果这实际上是这里的问题,那么这些makefile就会被破坏...... – andlabs

回答

1

无论出于何种原因,GTK + 3.20源代码树中的Makefile被破坏;根据n.m.的评论。这可能已经有了一个错误修正,如果不是修复的话。

但是,您不能在Ubuntu 14.04 LTS附带的GTK + 3.10中使用GTK + 3.20。你最好使用GTK + 3.10的例子和源代码。如果你真的想使用更新版本的GTK +,你可以使用jhbuild来建立一个独立于系统其他部分的环境(通常在/opt/gnome)来构建更新版本的GTK +。

+0

根据你以前的评论,我没有下载gtk + 3.10.9,配置成功。构建的例子但它搞乱了我的桌面环境,并开始得到一个低图形错误。必须通过make卸载进行卸载。 – user132797