/usr/share/doc/libglib2.0-doc/glib/glib-compiling.html is in libglib2.0-doc 2.32.1-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Compiling GLib Applications</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib.html" title="GLib Overview">
<link rel="prev" href="glib-cross-compiling.html" title="Cross-compiling the GLib package">
<link rel="next" href="glib-running.html" title="Running GLib Applications">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="glib-cross-compiling.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-running.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="glib-compiling"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">Compiling GLib Applications</span></h2>
<p>Compiling GLib Applications —
How to compile your GLib application
</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="idp2251352"></a><h2>Compiling GLib Applications on UNIX</h2>
<p>
To compile a GLib application, you need to tell the compiler where to
find the GLib header files and libraries. This is done with the
<span class="application">pkg-config</span> utility.
</p>
<p>
The following interactive shell session demonstrates how
<span class="application">pkg-config</span> is used (the actual output on
your system may be different):
</p>
<pre class="programlisting">
$ pkg-config --cflags glib-2.0
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
$ pkg-config --libs glib-2.0
-L/usr/lib -lm -lglib-2.0
</pre>
<p>
</p>
<p>
See the <a class="ulink" href="http://www.freedesktop.org/wiki/Software/pkg-config" target="_top">pkg-config website</a>
for more information about <span class="application">pkg-config</span>.
</p>
<p>
If your application uses or <span class="structname">GObject</span>
features, it must be compiled and linked with the options returned
by the following <span class="application">pkg-config</span> invocation:
</p>
<pre class="programlisting">
$ pkg-config --cflags --libs gobject-2.0
</pre>
<p>
</p>
<p>
If your application uses modules, it must be compiled and linked
with the options returned by one of the following
<span class="application">pkg-config</span> invocations:
</p>
<pre class="programlisting">
$ pkg-config --cflags --libs gmodule-no-export-2.0
$ pkg-config --cflags --libs gmodule-2.0
</pre>
<p>
The difference between the two is that gmodule-2.0 adds
<code class="option">--export-dynamic</code> to the linker flags,
which is often not needed.
</p>
<p>
The simplest way to compile a program is to use the "backticks"
feature of the shell. If you enclose a command in backticks
(<span class="emphasis"><em>not single quotes</em></span>), then its output will
be substituted into the command line before execution. So to
compile a GLib Hello, World, you would type the following:
</p>
<pre class="programlisting">
$ cc `pkg-config --cflags --libs glib-2.0` hello.c -o hello
</pre>
<p>
</p>
<p>
Deprecated GLib functions are annotated to make the compiler
emit warnings when they are used (e.g. with gcc, you need to use
the -Wdeprecated-declarations option). If these warnings are
problematic, they can be turned off by defining the preprocessor
symbol <code class="literal">GLIB_DISABLE_DEPRECATION_WARNINGS</code> by using the commandline
option <code class="literal">-DGLIB_DISABLE_DEPRECATION_WARNINGS</code>
</p>
<p>
GLib deprecation annotations are versioned; by defining the
macros <a class="link" href="glib-Version-Information.html#GLIB-VERSION-MIN-REQUIRED:CAPS" title="GLIB_VERSION_MIN_REQUIRED"><code class="literal">GLIB_VERSION_MIN_REQUIRED</code></a> and <a class="link" href="glib-Version-Information.html#GLIB-VERSION-MAX-ALLOWED:CAPS" title="GLIB_VERSION_MAX_ALLOWED"><code class="literal">GLIB_VERSION_MAX_ALLOWED</code></a>,
you can specify the range of GLib versions whose API you want
to use. APIs that were deprecated before or introduced after
this range will trigger compiler warnings.
</p>
<p>
The older deprecation mechanism of hiding deprecated interfaces
entirely from the compiler by using the preprocessor symbol
G_DISABLE_DEPRECATED is still used for deprecated macros,
enumeration values, etc. To detect uses of these in your code,
use the commandline option <code class="literal">-DG_DISABLE_DEPRECATED</code>.
</p>
<p>
The recommended way of using GLib has always been to only include the
toplevel headers <code class="filename">glib.h</code>,
<code class="filename">glib-object.h</code>, <code class="filename">gio.h</code>.
Starting with 2.32, GLib enforces this by generating an error
when individual headers are directly included.
</p>
<p>
Still, there are some exceptions; these headers have to be included
separately:
<code class="filename">gmodule.h</code>,
<code class="filename">glib-unix.h</code>,
<code class="filename">glib/gi18n-lib.h</code> or
<code class="filename">glib/gi18n.h</code> (see
the <a class="link" href="glib-I18N.html" title="Internationalization">Internationalization section</a>),
<code class="filename">glib/gprintf.h</code> and
<code class="filename">glib/gstdio.h</code>
(we don't want to pull in all of stdio).
</p>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.18</div>
</body>
</html>
|