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 to
g_application_get_type'
main.c:(.text+0x24): undefined reference to g_type_check_instance_cast'
main.c:(.text+0x35): undefined reference to
g_application_run'
exampleapp.o: In function example_app_class_intern_init':
exampleapp.c:(.text+0x14): undefined reference to
g_type_class_peek_parent'
exampleapp.c:(.text+0x36): undefined reference to g_type_class_adjust_private_offset'
exampleapp.o: In function
example_app_get_type':
exampleapp.c:(.text+0x66): undefined reference to g_once_init_enter'
exampleapp.c:(.text+0x84): undefined reference to
g_intern_static_string'
exampleapp.c:(.text+0x8c): undefined reference to gtk_application_get_type'
exampleapp.c:(.text+0xb4): undefined reference to
g_type_register_static_simple'
exampleapp.c:(.text+0xc9): undefined reference to g_once_init_leave'
exampleapp.o: In function
example_app_activate':
exampleapp.c:(.text+0x104): undefined reference to 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): undefined reference to g_type_check_instance_cast'
exampleapp.c:(.text+0x167): undefined reference to
gtk_application_get_windows'
exampleapp.c:(.text+0x18c): undefined reference to g_type_check_instance_cast'
exampleapp.c:(.text+0x1a9): undefined reference to
g_type_check_instance_cast'
exampleapp.c:(.text+0x1f5): undefined reference to gtk_window_get_type'
exampleapp.c:(.text+0x207): undefined reference to
g_type_check_instance_cast'
exampleapp.c:(.text+0x20f): undefined reference to gtk_window_present'
exampleapp.o: In function
example_app_class_init':
exampleapp.c:(.text+0x222): undefined reference to g_application_get_type'
exampleapp.c:(.text+0x234): undefined reference to
g_type_check_class_cast'
exampleapp.c:(.text+0x244): undefined reference to g_application_get_type'
exampleapp.c:(.text+0x256): undefined reference to
g_type_check_class_cast'
exampleapp.o: In function example_app_new':
exampleapp.c:(.text+0x294): undefined reference to
g_object_new'
exampleappwin.o: In function example_app_window_class_intern_init':
exampleappwin.c:(.text+0x14): undefined reference to
g_type_class_peek_parent'
exampleappwin.c:(.text+0x36): undefined reference to g_type_class_adjust_private_offset'
exampleappwin.o: In function
example_app_window_get_type':
exampleappwin.c:(.text+0x66): undefined reference to g_once_init_enter'
exampleappwin.c:(.text+0x84): undefined reference to
g_intern_static_string'
exampleappwin.c:(.text+0x8c): undefined reference to gtk_application_window_get_type'
exampleappwin.c:(.text+0xb4): undefined reference to
g_type_register_static_simple'
exampleappwin.c:(.text+0xc9): undefined reference to g_once_init_leave'
exampleappwin.o: In function
example_app_window_new':
exampleappwin.c:(.text+0x117): undefined reference to `g_object_new'
collect2: error: ld returned 1 exit status
make: *** [exampleapp] Error 1