-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilding.html
More file actions
401 lines (365 loc) · 17.6 KB
/
Copy pathbuilding.html
File metadata and controls
401 lines (365 loc) · 17.6 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE html>
<html lang="en">
<head>
<base href=".">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Compiling the GTK+ Libraries</title>
<link rel="stylesheet" href="assets/css/custom_bootstrap.css" type="text/css">
<link rel="stylesheet" href="assets/css/bootstrap-toc.min.css" type="text/css">
<link rel="stylesheet" href="assets/css/frontend.css" type="text/css">
<link rel="stylesheet" href="assets/css/jquery.mCustomScrollbar.min.css">
<link rel="stylesheet" href="assets/css/prism.css" type="text/css">
<script src="assets/js/mustache.min.js"></script>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/scrollspy.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/typeahead.jquery.min.js"></script>
<script src="assets/js/search.js"></script>
<script src="assets/js/isotope.pkgd.min.js"></script>
<script src="assets/js/compare-versions.js"></script>
<script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="assets/js/bootstrap-toc.min.js"></script>
<script src="assets/js/jquery.touchSwipe.min.js"></script>
<script src="assets/js/anchor.min.js"></script>
<script src="assets/js/tag_filtering.js"></script>
<script src="assets/js/language_switching.js"></script>
<script src="assets/js/lines_around_headings.js"></script>
<script src="assets/js/prism-core.js"></script>
<script src="assets/js/prism-autoloader.js"></script>
<script src="assets/js/prism_autoloader_path_override.js"></script>
<script src="assets/js/trie.js"></script>
</head>
<body class="no-script
" data-spy="scroll" data-target="#toc" data-offset="70">
<script>
$('body').removeClass('no-script');
</script>
<nav class="navbar navbar-fixed-top navbar-default" id="topnav">
<div class="container-fluid">
<div class="navbar-right">
<a id="toc-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-wrapper" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<form action="" class="navbar-form pull-right" id="navbar-search-form">
<div class="form-group has-feedback">
<input type="text" class="form-control input-sm" name="search" id="sidenav-lookup-field" placeholder="search" disabled>
<span class="glyphicon glyphicon-search form-control-feedback" id="search-mgn-glass"></span>
</div>
</form>
</div>
<div class="navbar-header">
<a id="sidenav-toggle">
<span class="glyphicon glyphicon-menu-right"></span>
<span class="glyphicon glyphicon-menu-left"></span>
</a>
<a id="home-link" href="index.html" class="hotdoc-navbar-brand">
<img src="assets/images/home.svg" alt="Home">
</a>
</div>
<div class="navbar-collapse collapse" id="navbar-wrapper">
<ul class="nav navbar-nav" id="menu">
</ul>
<div class="hidden-xs hidden-sm navbar-text navbar-center">
</div>
</div>
</div>
</nav>
<main>
<div data-extension="gi-extension" data-hotdoc-in-toplevel="True" data-hotdoc-project="gtk-4.0.0" data-hotdoc-ref="building.html" class="page_container" id="page-wrapper" data-hotdoc-meta-gi-languages="['csharp']" data-hotdoc-meta-gi-language="c">
<script src="assets/js/utils.js"></script>
<div class="panel panel-collapse oc-collapsed" id="sidenav" data-hotdoc-role="navigation">
<script src="assets/js/navigation.js"></script>
<script src="assets/js/sitemap.js"></script>
</div>
<div id="body">
<div id="main">
<div id="page-description" data-hotdoc-source="building.markdown" data-hotdoc-role="main">
<h1 id="building-gtk">Building GTK+</h1>
<p>Before we get into the details of how to compile GTK+, we should mention
that in many cases, binary packages of GTK+ prebuilt for your operating
system will be available, either from your operating system vendor or
from independent sources. If such a set of packages is available,
installing it will get you programming with GTK+ much faster than
building it yourself. In fact, you may well already have GTK+ installed
on your system already.</p>
<p>In order to build GTK+, you will need meson installed on your system. On
Linux, and other UNIX-like operating systems, you will also need ninja.
This guide does not cover how to install these two requirements, but you
can refer to the <a href="http://mesonbuild.com">Meson website</a> for more
information. The <a href="https://ninja-build.org">Ninja</a> build tool is also
usable on various operating systems, so we will refer to it in the
examples.</p>
<p>If you are building GTK+ from a source distribution or from a Git clone,
you will need to use meson to configure the project. The most commonly
useful argument is the --prefix one, which determines where the files
will go once installed. To install GTK+ under a prefix like <code>/opt/gtk</code>
you would run Meson as:</p>
<pre><code> meson --prefix /opt/gtk builddir
</code></pre>
<p>Meson will create the <code>builddir</code> directory and place all the build
artefacts there.</p>
<p>You can get a list of all available options for the build by running
meson configure.</p>
<p>After Meson successfully configured the build directory, you then can
run the build, using Ninja:</p>
<pre><code> cd builddir
ninja
ninja install
</code></pre>
<p>If you don't have permission to write to the directory you are
installing in, you may have to change to root temporarily before running
<code>ninja install</code>.</p>
<p>Several environment variables are useful to pass to set before running
configure. CPPFLAGS contains options to pass to the C compiler, and is
used to tell the compiler where to look for include files. The LDFLAGS
variable is used in a similar fashion for the linker. Finally the
PKG_CONFIG_PATH environment variable contains a search path that
<code>pkg-config</code> (see below) uses when looking for files describing how to
compile programs using different libraries. If you were installing GTK+
and it's dependencies into <code>/opt/gtk</code>, you might want to set these
variables as:</p>
<pre><code> CPPFLAGS="-I/opt/gtk/include"
LDFLAGS="-L/opt/gtk/lib"
PKG_CONFIG_PATH="/opt/gtk/lib/pkgconfig"
export CPPFLAGS LDFLAGS PKG_CONFIG_PATH
</code></pre>
<p>You may also need to set the LD_LIBRARY_PATH environment variable so
the systems dynamic linker can find the newly installed libraries, and
the PATH environment program so that utility binaries installed by the
various libraries will be found.</p>
<pre><code> LD_LIBRARY_PATH="/opt/gtk/lib"
PATH="/opt/gtk/bin:$PATH"
export LD_LIBRARY_PATH PATH
</code></pre>
<h1 id="dependencies">Dependencies</h1>
<p>Before you can compile the GTK+ widget toolkit, you need to have various
other tools and libraries installed on your system. Dependencies of GTK+
have their own build systems, so you will need to refer to their own
installation instructions.</p>
<p>A particular important tool used by GTK+ to find its dependencies is
pkg-config.</p>
<p><a href="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</a> is a
tool for tracking the compilation flags needed for libraries that are
used by the GTK+ libraries. (For each library, a small <code>.pc</code> text file
is installed in a standard location that contains the compilation flags
needed for that library along with version number information.)</p>
<p>Some of the libraries that GTK+ depends on are maintained by by the GTK+
team: GLib, GdkPixbuf, Pango, ATK and GObject Introspection. Other
libraries are maintained separately.</p>
<ul>
<li>
<p>The GLib library provides core non-graphical functionality such as
high level data types, Unicode manipulation, and an object and type
system to C programs. It is available from
<a href="https://download.gnome.org/sources/glib/">here</a>.</p>
</li>
<li>
<p>The <a href="https://git.gnome.org/browse/gdk-pixbuf/">GdkPixbuf library</a>
provides facilities for loading images in a variety of file formats.
It is available
<a href="https://download.gnome.org/sources/gdk-pixbuf/">here</a>.</p>
</li>
<li>
<p><a href="http://www.pango.org">Pango</a> is a library for internationalized
text handling. It is available
<a href="https://download.gnome.org/sources/pango/">here</a>.</p>
</li>
<li>
<p>ATK is the Accessibility Toolkit. It provides a set of generic
interfaces allowing accessibility technologies such as screen
readers to interact with a graphical user interface. It is available
<a href="https://download.gnome.org/sources/atk/">here</a>.</p>
</li>
<li>
<p><a href="https://wiki.gnome.org/Projects/GObjectIntrospection">Gobject
Introspection</a>
is a framework for making introspection data available to language
bindings. It is available
<a href="https://download.gnome.org/sources/gobject-introspection/">here</a>.</p>
</li>
</ul>
<!-- end list -->
<ul>
<li>
<p>The <a href="https://www.gnu.org/software/libiconv/">GNU libiconv library</a>
is needed to build GLib if your system doesn't have the <code>iconv()</code>
function for doing conversion between character encodings. Most
modern systems should have <code>iconv()</code>.</p>
</li>
<li>
<p>The libintl library from the <a href="https://www.gnu.org/software/gettext/">GNU gettext
package</a> is needed if your
system doesn't have the <code>gettext()</code> functionality for handling
message translation databases.</p>
</li>
<li>
<p>The libraries from the X window system are needed to build Pango and
GTK+. You should already have these installed on your system, but
it's possible that you'll need to install the development
environment for these libraries that your operating system vendor
provides.</p>
</li>
<li>
<p>The
<a href="https://www.freedesktop.org/wiki/Software/fontconfig/">fontconfig</a>
library provides Pango with a standard way of locating fonts and
matching them against font names.</p>
</li>
<li>
<p><a href="https://www.cairographics.org">Cairo</a> is a graphics library that
supports vector graphics and image compositing. Both Pango and GTK+
use Cairo for drawing.</p>
</li>
<li>
<p><a href="https://github.com/anholt/libepoxy">libepoxy</a> is a library that
abstracts the differences between different OpenGL libraries. GTK+
uses it for cross-platform GL support and for its own drawing.</p>
</li>
<li>
<p><a href="https://github.com/anholt/libepoxy">Graphene</a> is a library that
provides vector and matrix types for 2D and 3D transformations. GTK+
uses it internally for drawing.</p>
</li>
<li>
<p>The <a href="https://wayland.freedesktop.org">Wayland</a> libraries are needed
to build GTK+ with the Wayland backend.</p>
</li>
<li>
<p>The
<a href="https://www.freedesktop.org/wiki/Software/shared-mime-info">shared-mime-info</a>
package is not a hard dependency of GTK+, but it contains
definitions for mime types that are used by GIO and, indirectly, by
GTK+. gdk-pixbuf will use GIO for mime type detection if possible.
For this to work, shared-mime-info needs to be installed and
XDG_DATA_DIRS set accordingly at configure time. Otherwise,
gdk-pixbuf falls back to its built-in mime type detection.</p>
</li>
</ul>
<h1 id="building-and-testing-gtk">Building and testing GTK+</h1>
<p>First make sure that you have the necessary external dependencies
installed: <code>pkg-config</code>, Meson, Ninja, the JPEG, PNG, and TIFF
libraries, FreeType, and, if necessary, libiconv and libintl. To get
detailed information about building these packages, see the
documentation provided with the individual packages. On any average
Linux system, it's quite likely you'll have all of these installed
already, or they will be easily accessible through your operating system
package repositories.</p>
<p>Then build and install the GTK+ libraries in the order: GLib, Cairo,
Pango, ATK, then GTK+. For each library, follow the instructions they
provide, and make sure to share common settings between them and the
GTK+ build; if you are using a separate prefix for GTK+, for instance,
you will need to use the same prefix for all its dependencies you build.
If you're lucky, this will all go smoothly, and you'll be ready to
<a href="compiling.html">start compiling your own GTK+ applications</a>. You
can test your GTK+ installation by running the <code>gtk4-demo</code> program that
GTK+ installs.</p>
<p>If one of the projects you're configuring or building fails, look
closely at the error messages printed; these will often provide useful
information as to what went wrong. Every build system has its own log
that can help you understand the issue you're encountering. If all else
fails, you can ask for help on the gtk-list mailing list. See <a href="resources.html">Mailing
lists and bug reports</a> for more information.</p>
<h1 id="extra-configuration-options">Extra Configuration Options</h1>
<p>In addition to the normal options provided by Meson, GTK+ defines
various arguments that modify what should be built. <code>meson</code>
-Ddisable-modules=true -Ddisable-modules=false
-Dwith-included-immodules=MODULE1,MODULE2,...
-Dwith-included-immodules=all -Dwith-included-immodules=none
-Ddocumentation=true -Ddocumentation=false -Dman-pages=true
-Dman-pages=false -Denable-cups-print-backend=yes
-Denable-cups-print-backend=no -Denable-cups-print-backend=auto
-Denable-papi-print-backend=yes -Denable-papi-print-backend=no
-Denable-papi-print-backend=auto -Denable-cloudprint-print-backend=yes
-Denable-cloudprint-print-backend=no
-Denable-cloudprint-print-backend=auto -Denable-test-print-backend=yes
-Denable-test-print-backend=no -Denable-test-print-backend=auto
-Denable-colord=yes -Denable-colord=no -Denable-colord=auto
-Denable-vulkan=yes -Denable-vulkan=no -Denable-vulkan=auto
-Denable-x11-backend=true -Denable-x11-backend=false
-Denable-xinerama=true -Denable-xinerama=false
-Denable-win32-backend=true -Denable-win32-backend=false
-Denable-quartz-backend=true -Denable-quartz-backend=false
-Denable-broadway-backend=true -Denable-broadway-backend=false
-Denable-wayland-backend=true -Denable-wayland-backend=false
-Denable-mir-backend=true -Denable-mir-backend=false
-Dintrospection=true -Dintrospection=false</p>
<p><strong>disable-modules.</strong></p>
<p>Normally GTK+ will try to build the input method modules as little
shared libraries that are loaded on demand. The disable-modules option
indicates that they should all be built statically into the GTK+ library
instead. This is useful for people who need to produce statically-linked
binaries. If disable-modules is not specified, then the <code>configure</code>
script will try to auto-detect whether shared modules work on your
system.</p>
<p><strong>with-included-immodules.</strong></p>
<p>This option allows you to specify which input method modules you want to
include directly into the GTK+ shared library, as opposed to building
them as loadable modules.</p>
<p><strong>enable-xinerama.</strong></p>
<p>By default GTK+ will try to link against the Xinerama libraries if they
are found. This options can be used to explicitly control whether
Xinerama should be used.</p>
<p><strong>enable-documentation and enable-man-pages.</strong></p>
<p>The gtk-doc package is used to generate the reference documentation
included with GTK+. By default support for gtk-doc is disabled because
it requires various extra dependencies to be installed. If you have
gtk-doc installed and are modifying GTK+, you may want to enable gtk-doc
support by passing in enable-documentation.</p>
<p>Additionally, some tools provided by GTK+ have their own manual pages
generated using a similar set of dependencies; if you have xsltproc then
you can generate manual pages by passing enable-man-pages when
configuring the build.</p>
<p><strong>enable-cups-print-backend, enable-papi-print-backend,
enable-cloudprint-print-backend, and enable-test-print-backend.</strong></p>
<p>By default, GTK+ will try to build various print backends if their
dependencies are found. These options can be used to explicitly control
whether each print backend should be built or not.</p>
<p><strong>enable-x11-backend, enable-win32-backend, enable-quartz-backend,
enable-broadway-backend, enable-wayland-backend, and
enable-mir-backend.</strong></p>
<p>Enable specific backends for GDK. If none of these options are given,
the Wayland backend will be enabled by default, if the platform is
Linux; the X11 backend will also be enabled by default, unless the
platform is Windows, in which case the default is win32, or the platform
is macOS, in which case the default is quartz. If any backend is
explicitly enabled or disabled, no other platform will be enabled
automatically.</p>
<p><strong>introspection.</strong></p>
<p>Allows to disable building introspection support. This is option is
mainly useful for shortening turnaround times on developer systems.
Installed builds of GTK+ should always have introspection support.</p>
<p><strong>build-tests demos.</strong></p>
<p>By default, GTK+ will build quite a few tests and demos. While these are
useful on a developer system, they are not needed when GTK+ is built
e.g. for a flatpak runtime. These options allow to disable building
tests and demos.</p>
</div>
</div>
<div id="search_results">
<p>The results of the search are</p>
</div>
<hr>
<div id="footer">
</div>
</div>
<div id="toc-column">
<div class="edit-button">
</div>
<div id="toc-wrapper">
<nav id="toc"></nav>
</div>
</div>
</div>
</main>
</body>
<script src="assets/js/navbar_offset_scroller.js"></script>
</html>