1
votes

I am trying to built some sample gtk+ examples that came with the gtk+ sources. My need was only to have a gtk+ UI to a C program. I went about downloading and building gtk+ but realised (through SO) that this was not needed and that I only need 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.

EDIT: NOTE: Issue is not with the sequence of libraries or includes as I am using the makefile that came with gtk+.

I tried compiling an example that I had with the gtk+ code I downloaded. I get the below errors. The other queries on this topic mentioned that the order of the flags matter, but in this case I have used the makefile that came with the sources. Should I be installing something more than the libgtk-3-dev library (running on 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: In function main': main.c:(.text+0x11): undefined reference tog_application_get_type' main.c:(.text+0x24): undefined reference to g_type_check_instance_cast' main.c:(.text+0x35): undefined reference tog_application_run' exampleapp.o: In function example_app_class_intern_init': exampleapp.c:(.text+0x14): undefined reference tog_type_class_peek_parent' exampleapp.c:(.text+0x36): undefined reference to g_type_class_adjust_private_offset' exampleapp.o: In functionexample_app_get_type': exampleapp.c:(.text+0x66): undefined reference to g_once_init_enter' exampleapp.c:(.text+0x84): undefined reference tog_intern_static_string' exampleapp.c:(.text+0x8c): undefined reference to gtk_application_get_type' exampleapp.c:(.text+0xb4): undefined reference tog_type_register_static_simple' exampleapp.c:(.text+0xc9): undefined reference to g_once_init_leave' exampleapp.o: In functionexample_app_activate': exampleapp.c:(.text+0x104): undefined reference to g_type_check_instance_cast' exampleapp.c:(.text+0x115): undefined reference togtk_window_get_type' exampleapp.c:(.text+0x127): undefined reference to g_type_check_instance_cast' exampleapp.c:(.text+0x12f): undefined reference togtk_window_present' exampleapp.o: In function example_app_open': exampleapp.c:(.text+0x14d): undefined reference togtk_application_get_type' exampleapp.c:(.text+0x15f): undefined reference to g_type_check_instance_cast' exampleapp.c:(.text+0x167): undefined reference togtk_application_get_windows' exampleapp.c:(.text+0x18c): undefined reference to g_type_check_instance_cast' exampleapp.c:(.text+0x1a9): undefined reference tog_type_check_instance_cast' exampleapp.c:(.text+0x1f5): undefined reference to gtk_window_get_type' exampleapp.c:(.text+0x207): undefined reference tog_type_check_instance_cast' exampleapp.c:(.text+0x20f): undefined reference to gtk_window_present' exampleapp.o: In functionexample_app_class_init': exampleapp.c:(.text+0x222): undefined reference to g_application_get_type' exampleapp.c:(.text+0x234): undefined reference tog_type_check_class_cast' exampleapp.c:(.text+0x244): undefined reference to g_application_get_type' exampleapp.c:(.text+0x256): undefined reference tog_type_check_class_cast' exampleapp.o: In function example_app_new': exampleapp.c:(.text+0x294): undefined reference tog_object_new' exampleappwin.o: In function example_app_window_class_intern_init': exampleappwin.c:(.text+0x14): undefined reference tog_type_class_peek_parent' exampleappwin.c:(.text+0x36): undefined reference to g_type_class_adjust_private_offset' exampleappwin.o: In functionexample_app_window_get_type': exampleappwin.c:(.text+0x66): undefined reference to g_once_init_enter' exampleappwin.c:(.text+0x84): undefined reference tog_intern_static_string' exampleappwin.c:(.text+0x8c): undefined reference to gtk_application_window_get_type' exampleappwin.c:(.text+0xb4): undefined reference tog_type_register_static_simple' exampleappwin.c:(.text+0xc9): undefined reference to g_once_init_leave' exampleappwin.o: In functionexample_app_window_new': exampleappwin.c:(.text+0x117): undefined reference to `g_object_new' collect2: error: ld returned 1 exit status make: *** [exampleapp] Error 1

1
Ubuntu 14.04 only comes with GTK+ 3.10; you won't be able to build examples for newer versions of GTK+ with it. Get a version of the GTK+ 3.10 source code and the examples should build.andlabs
@n.m. They are trying to build an example that comes with the GTK+ source, not their own program. These examples have a correct makefile already. If that actually is the problem here, then these makefiles are broken...andlabs
@andlabs : oops ! :( I overlooked that part which said the example came with gtk. Thanks for the time with my answer..sjsam
Makefile.example in the gtk+ tree is broken.n. 1.8e9-where's-my-share m.

1 Answers

1
votes

For whatever reason the Makefile in the GTK+ 3.20 source tree is broken; as per n.m.'s comment. There might already be a bugfix, if not a fix, for that.

But you can't use GTK+ 3.20 with the GTK+ 3.10 that comes with Ubuntu 14.04 LTS. You're better off using the GTK+ 3.10 examples and source code. If you really want to use a newer version of GTK+, you can use jhbuild to set up an environment separate from the rest of the system (typically in /opt/gnome) to build a newer versions of GTK+ into.