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 680241 - Instructions on how to build a GTK app won't work with recent GCC versions
Instructions on how to build a GTK app won't work with recent GCC versions
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Documentation
3.5.x
Other Linux
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-07-19 10:17 UTC by Luis Menina
Modified: 2013-06-20 22:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
reorder compiler command line in documentation (1.98 KB, patch)
2012-11-13 14:28 UTC, David King
reviewed Details | Review
updated patch with more compatible ordering (2.04 KB, patch)
2012-11-13 15:10 UTC, David King
committed Details | Review

Description Luis Menina 2012-07-19 10:17:04 UTC
From http://developer.gnome.org/gtk3/stable/gtk-compiling.html

<pre>cc `pkg-config --cflags --libs gtk+-3.0` hello.c -o hello</pre>

I you follow these instructions, you'll have errors on recent GCC versions:
http://stackoverflow.com/questions/11546877/compiling-and-linking-gtk-3-with-c-project-on-ubuntu

This should be replaced by:
<pre>cc hello.c `pkg-config --cflags --libs gtk+-3.0` -o hello</pre>
Comment 1 Frederic Peters 2012-07-19 12:32:50 UTC
Hey Luis, thanks for the report; that documentation is from GTK+, I'm reassigning.
Comment 2 David King 2012-11-13 14:28:16 UTC
Created attachment 228896 [details] [review]
reorder compiler command line in documentation
Comment 3 Emmanuele Bassi (:ebassi) 2012-11-13 14:32:23 UTC
Review of attachment 228896 [details] [review]:

::: docs/reference/gtk/compiling.sgml
@@ +43,3 @@
 a GTK+ Hello, World, you would type the following:
 <programlisting>
+$ cc hello.c `pkg-config --cflags --libs gtk+-3.0` -o hello

I'd rather have the portable version, i.e.:

  cc `pkg-config --cflags gtk+-3.0` hello.c -o hello `pkg-config --libs gtk+-3.0`

given that it'll work on Windows as well.
Comment 4 David King 2012-11-13 15:10:23 UTC
Created attachment 228902 [details] [review]
updated patch with more compatible ordering

Thanks for the review, I updated the patch.
Comment 5 Luis Menina 2012-11-13 23:51:10 UTC
(In reply to comment #3)
> I'd rather have the portable version, i.e.:
> 
>   cc `pkg-config --cflags gtk+-3.0` hello.c -o hello `pkg-config --libs
> gtk+-3.0`
> 
> given that it'll work on Windows as well.

Any reference on that ? I'm not aware of differences on behavior here between Linux and Windows.

Another thing is the possibility of using the $() notation instead of backticks. Newcommers often don't recognize the backticks and use normal single quotes, so the $() notation would be better, but I'm not sure it is supported by all shells. What do you think?
Comment 6 Luis Menina 2013-02-05 15:14:59 UTC
About $() vs backticks, it seems every POSIX-compliant shell would allow the use of $(), so I would go for it:
http://unix.stackexchange.com/questions/5778/whats-the-difference-between-stuff-and-stuff
Comment 7 Matthias Clasen 2013-04-29 03:59:55 UTC
Review of attachment 228902 [details] [review]:

sure
Comment 8 Luis Menina 2013-06-20 22:55:16 UTC
(In reply to comment #5)
> (In reply to comment #3)
> > I'd rather have the portable version, i.e.:
> > 
> >   cc `pkg-config --cflags gtk+-3.0` hello.c -o hello `pkg-config --libs
> > gtk+-3.0`
> > 
> > given that it'll work on Windows as well.
> 
> Any reference on that ? I'm not aware of differences on behavior here between
> Linux and Windows.

For the record, this is has been confirmed by Tor Lillqvist too:
https://mail.gnome.org/archives/gtk-app-devel-list/2010-February/msg00035.html