1 <refentry id="glib-compiling" revision="17 Jan 2002">
3 <refentrytitle>Compiling GLib Applications</refentrytitle>
4 <manvolnum>3</manvolnum>
5 <refmiscinfo>GLib Library</refmiscinfo>
9 <refname>Compiling GLib Applications</refname>
11 How to compile your GLib application
16 <title>Compiling GLib Applications on UNIX</title>
19 To compile a GLib application, you need to tell the compiler where to
20 find the GLib header files and libraries. This is done with the
21 <application>pkg-config</application> utility.
24 The following interactive shell session demonstrates how
25 <application>pkg-config</application> is used (the actual output on
26 your system may be different):
28 $ pkg-config --cflags glib-2.0
29 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
30 $ pkg-config --libs glib-2.0
31 -L/usr/lib -lm -lglib-2.0
35 If your application uses modules, threads or <structname>GObject</structname>
36 features, it must be compiled and linked with the options returned by the
37 following <application>pkg-config</application> invokations:
39 $ pkg-config --cflags --libs gmodule-2.0
40 $ pkg-config --cflags --libs gthread-2.0
41 $ pkg-config --cflags --libs gobject-2.0
45 The simplest way to compile a program is to use the "backticks"
46 feature of the shell. If you enclose a command in backticks
47 (<emphasis>not single quotes</emphasis>), then its output will be
48 substituted into the command line before execution. So to compile
49 a GLib Hello, World, you would type the following:
51 $ cc `pkg-config --cflags --libs glib-2.0` hello.c -o hello