After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 740537 - Cannot build example application
Cannot build example application
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-11-22 17:51 UTC by sallyx
Modified: 2014-12-15 15:22 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description sallyx 2014-11-22 17:51:07 UTC
Hi,
I tried to lern GTK+ using https://developer.gnome.org/gtk3/stable/ch01s05.html.

1) From application4 (https://git.gnome.org/browse/gtk+/tree/examples) i cant build it:

glib-compile-resources exampleapp.gresource.xml --target=resources.c --generate-source
gcc `pkg-config --cflags gtk+-3.0` -o exampleapp *.c `pkg-config --libs gtk+-3.0`


/tmp/ccAL6x9K.o: In function `example_app_startup':
exampleapp.c:(.text+0x19b): undefined reference to `gtk_application_set_accels_for_action'
collect2: error: ld returned 1 exit status

(`gtk_application_set_accels_for_action' is not even mentioned in the documentation, so I have no idea what it is)

2) Also in every applicationX is in main.c 
#include <exampleapp.h>

but it should be

#include "exampleapp.h"

otherwise I cant build it.

3) All the "Building applications" documentation is in "Getting Started with GTK+"

I tried to start with GTK+, but I do not understand it almost at all. I do not know what G_APPLICATION is for and where to find it in the documentation, I do not know what is code like 

struct _ExampleApp
{
  GtkApplication parent;
};

struct _ExampleAppClass
{
  GtkApplicationClass parent_class;
};

G_DEFINE_TYPE(ExampleApp, example_app, GTK_TYPE_APPLICATION);

for and where is it documented etc. So, I think that "Building applications" section should not definitely be in "Getting Started with GTK+", or there should be something before explaining all the thinks I do not know ..
Comment 1 Emmanuele Bassi (:ebassi) 2014-11-22 18:02:26 UTC
(In reply to comment #0)
> Hi,
> I tried to lern GTK+ using
> https://developer.gnome.org/gtk3/stable/ch01s05.html.
> 
> 1) From application4 (https://git.gnome.org/browse/gtk+/tree/examples) i cant
> build it:
> 
> glib-compile-resources exampleapp.gresource.xml --target=resources.c
> --generate-source
> gcc `pkg-config --cflags gtk+-3.0` -o exampleapp *.c `pkg-config --libs
> gtk+-3.0`
> 
> 
> /tmp/ccAL6x9K.o: In function `example_app_startup':
> exampleapp.c:(.text+0x19b): undefined reference to
> `gtk_application_set_accels_for_action'
> collect2: error: ld returned 1 exit status

you need the current stable version of GTK+ to build the examples linked from the documentation of the stable version of GTK+. the stable version of GTK+ currently is 3.14.

if you have an older version of GTK+ you will need to go to:

  https://developer.gnome.org/gtk3/

and select the version of the documentation from that page.

> 2) Also in every applicationX is in main.c 
> #include <exampleapp.h>
> 
> but it should be
> 
> #include "exampleapp.h"
> 
> otherwise I cant build it.

that's just an inclusion directive for your compiler.
 
> 3) All the "Building applications" documentation is in "Getting Started with
> GTK+"

getting started with GTK+ implies also knowledge of the core libraries that GTK+ depends on — namely: GLib/GObject, Cairo, and Pango. the GTK+ documentation does not cover those libraries, but you can navigate developer.gnome.org to learn how to use them.

in particular, knowledge of GObject — types, inheritance, classes, signals, properties — is a requirement for using GTK+.

if you're looking for entry level documentation on the core platform, you should probably start from the beginners tutorials:

https://developer.gnome.org/gnome-devel-demos/stable/beginner.c.html.en

there are also various tutorials on the core GNOME platform libraries linked from developer.gnome.org that you can use.
Comment 2 sallyx 2014-11-23 11:22:21 UTC
Hi, 
thank you for you answer.

1) I have version 3.10 and I downloaded the examples from git, so it was my mistake.

2) I still think it is a bug. You use #include <exampleapp.h> only in main.c, in other files you use #include "exampleapp.h" whitch is a) inconsistent, b) confusing

If you will insist on #include <exampleapp.h> , then the bug is in example how to compile:

 gcc `pkg-config --cflags gtk+-3.0` -o example-0 example-0.c `pkg-config --libs gtk+-3.0`

It should be:
 gcc `pkg-config --cflags gtk+-3.0` -o example-0 example-0.c `pkg-config --libs gtk+-3.0` -I.

3) Thank you for this information, I will have look at it. Maybe this information should be in some "Prerequest" section in "Getting Started with GTK+".