]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/compiling.sgml
Add info about single includes when compiling GTK+ apps
[~andy/gtk] / docs / reference / gtk / compiling.sgml
1 <?xml version="1.0"?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3                "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
4 ]>
5 <refentry id="gtk-compiling" revision="4 Feb 2001">
6 <refmeta>
7 <refentrytitle>Compiling GTK+ Applications</refentrytitle>
8 <manvolnum>3</manvolnum>
9 <refmiscinfo>GTK Library</refmiscinfo>
10 </refmeta>
11
12 <refnamediv>
13 <refname>Compiling GTK+ Applications</refname>
14 <refpurpose>
15 How to compile your GTK+ application
16 </refpurpose>
17 </refnamediv>
18
19 <refsect1>
20 <title>Compiling GTK+ Applications on UNIX</title>
21
22 <para>
23 To compile a GTK+ application, you need to tell the compiler where to 
24 find the GTK+ header files and libraries. This is done with the
25 <literal>pkg-config</literal> utility.
26 </para>
27 <para>
28 The following interactive shell session demonstrates how
29 <literal>pkg-config</literal> is used (the actual output on 
30 your system may be different):
31 <programlisting>
32 $ pkg-config --cflags gtk+-2.0
33  -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/atk-1.0  
34 $ pkg-config --libs gtk+-2.0
35  -L/usr/lib -L/usr/X11R6/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -lXi -lgdk_pixbuf-2.0 -lm -lpangox -lpangoxft -lXft -lXrender -lXext -lX11 -lfreetype -lpango -latk -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0  
36 </programlisting>
37 </para>
38 <para>
39 The simplest way to compile a program is to use the "backticks"
40 feature of the shell. If you enclose a command in backticks
41 (<emphasis>not single quotes</emphasis>), then its output will be
42 substituted into the command line before execution. So to compile 
43 a GTK+ Hello, World, you would type the following:
44 <programlisting>
45 $ cc `pkg-config --cflags --libs gtk+-2.0` hello.c -o hello
46 </programlisting>
47 </para>
48
49 <para>
50 If you want to make sure that your program doesn't use any deprecated 
51 functions, you can define the preprocessor symbol GTK_DISABLE_DEPRECATED
52 by using the command line option <literal>-DGTK_DISABLE_DEPRECATED=1</literal>.
53 There are similar symbols GDK_DISABLE_DEPRECATED, 
54 GDK_PIXBUF_DISABLE_DEPRECATED and G_DISABLE_DEPRECATED for GDK, GdkPixbuf and
55 GLib. 
56 </para>
57
58 <para>
59 If you want to make sure that your program doesn't use any functions which 
60 may be problematic in a multihead setting, you can define the preprocessor
61 symbol GDK_MULTIHEAD_SAFE by using the command line option 
62 <literal>-DGTK_MULTIHEAD_SAFE=1</literal>.
63 </para>
64
65 <para>
66 The recommended way of using GTK+ has always been to only include the
67 toplevel headers <filename>gtk.h</filename>, <filename>gdk.h</filename>, 
68 <filename>gdk-pixbuf.h</filename>.
69 If you want to make sure that your program follows this recommended
70 practise, you can define the preprocessor symbols GTK_DISABLE_SINGLE_INCLUDES
71 and GDK_PIXBUF_DISABLE_SINGLE_INCLUDES to make GTK+ generate an error
72 when individual headers are directly included.
73 There are some exceptions: <filename>gdkkeysyms.h</filename> is not included in
74 <filename>gdk.h</filename> because the file is quite large; see
75 <link linkend="gdk-Keyboard-Handling">Key Values documentation</link>.
76 <filename>gdkx.h</filename> must be included independently because It's
77 platform-specific; see
78 <link linkend="gdk-X-Window-System-Interaction">X Window System Interaction</link>
79 documentation.
80 The same for <filename>gtkunixprint.h</filename> if you use the non-portable
81 <link linkend="GtkPrintUnixDialog">GtkPrintUnixDialog</link> API.
82 </para>
83
84 </refsect1>
85 </refentry>