Re: Compiling glib applications
- From: Lanoxx <lanoxx gmx net>
- Cc: desktop-devel-list <desktop-devel-list gnome org>
- Subject: Re: Compiling glib applications
- Date: Thu, 09 Aug 2012 23:04:37 +0200
Alright, thanks for all the messages. Here is the patch. :)
On 09/08/12 20:20, Dan Williams wrote:
On Thu, 2012-08-09 at 14:46 +0200, Lanoxx wrote:
Today I was writing some simple glib application and had a look at
this page [1], to get some advice on how to compile and link my
program with glib. However for me the advice was not entirely correct,
since it give this example line:
cc `pkg-config --cflags --libs glib-2.0` hello.c -o hello
I adjusted it a bit to my file names and added c99 support:
gcc `pkg-config --cflags glib-2.0` `pkg-config --libs glib-2.0`
main.c -o main --std=c99
But it turns out this is wrong, and the correct way is:
gcc main.c `pkg-config --cflags glib-2.0` `pkg-config --libs
glib-2.0` -o main --std=c99
Or, more simply:
gcc main.c `pkg-config --libs --cflags glib-2.0 <other-lib> <another-lib>` -o main.c
No need to have multiple pkg-config invocations at all; one does just
fine.
Right, I splitted that up, while I was figuring out why I was getting a
link error.
Dan
Lanoxx
>From c2184af090f5cdcc85b909e8f333e98f0b4d41c4 Mon Sep 17 00:00:00 2001
From: Sebastian Geiger <sbastig gmx net>
Date: Thu, 9 Aug 2012 23:01:29 +0200
Subject: [PATCH] compiling.xml: Add note and fix gcc example
---
docs/reference/glib/compiling.xml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/docs/reference/glib/compiling.xml b/docs/reference/glib/compiling.xml
index 9add70b..03ae310 100644
--- a/docs/reference/glib/compiling.xml
+++ b/docs/reference/glib/compiling.xml
@@ -66,9 +66,12 @@ feature of the shell. If you enclose a command in backticks
be substituted into the command line before execution. So to
compile a GLib Hello, World, you would type the following:
<programlisting>
-$ cc `pkg-config --cflags --libs glib-2.0` hello.c -o hello
+$ cc hello.c `pkg-config --cflags --libs glib-2.0` -o hello
</programlisting>
</para>
+<note><para>
+Note that the name of the file must come before the other options (such as <\emphasis>pkg-config</emphasis>), or else you may get an error from the linker.
+</para></note>
<para>
Deprecated GLib functions are annotated to make the compiler
--
1.7.9.5
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]