-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiling.html
More file actions
184 lines (152 loc) · 7.28 KB
/
Copy pathcompiling.html
File metadata and controls
184 lines (152 loc) · 7.28 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
<!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 GTK+ Applications</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="compiling.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="compiling.markdown" data-hotdoc-role="main">
<h1 id="compiling-gtk-applications-on-unix">Compiling GTK+ Applications on UNIX</h1>
<p>To compile a GTK+ application, you need to tell the compiler where to
find the GTK+ header files and libraries. This is done with the
<code>pkg-config</code> utility.</p>
<p>The following interactive shell session demonstrates how <code>pkg-config</code> is
used (the actual output on your system may be different):</p>
<pre><code>$ pkg-config --cflags gtk+-4.0
-pthread -I/usr/include/gtk-4.0 -I/usr/lib64/gtk-4.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
$ pkg-config --libs gtk+-4.0
-pthread -lgtk-4 -lgdk-4 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
</code></pre>
<p>The simplest way to compile a program is to use the "backticks" feature
of the shell. If you enclose a command in backticks (<em>not single
quotes</em>), then its output will be substituted into the command line
before execution. So to compile a GTK+ Hello, World, you would type the
following:</p>
<pre><code>$ cc `pkg-config --cflags gtk+-4.0` hello.c -o hello `pkg-config --libs gtk+-4.0`
</code></pre>
<p>Deprecated GTK+ 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
%GDK_DISABLE_DEPRECATION_WARNINGS by using the commandline option
<code>-DGDK_DISABLE_DEPRECATION_WARNINGS</code></p>
<p>GTK+ deprecation annotations are versioned; by defining the macros
%GDK_VERSION_MIN_REQUIRED and %GDK_VERSION_MAX_ALLOWED, you can
specify the range of GTK+ versions whose API you want to use. APIs that
were deprecated before or introduced after this range will trigger
compiler warnings.</p>
<p>Here is how you would compile hello.c if you want to allow it to use
symbols that were not deprecated in
3.2:</p>
<pre><code>$ cc `pkg-config --cflags gtk+-4.0` -DGDK_VERSION_MIN_REQIRED=GDK_VERSION_3_2 hello.c -o hello `pkg-config --libs gtk+-4.0`
</code></pre>
<p>And here is how you would compile hello.c if you don't want it to use
any symbols that were introduced after
3.4:</p>
<pre><code>$ cc `pkg-config --cflags gtk+-4.0` -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4 hello.c -o hello `pkg-config --libs gtk+-4.0`
</code></pre>
<p>The older deprecation mechanism of hiding deprecated interfaces entirely
from the compiler by using the preprocessor symbol
GTK_DISABLE_DEPRECATED is still used for deprecated macros,
enumeration values, etc. To detect uses of these in your code, use the
commandline option <code>-DGTK_DISABLE_DEPRECATED</code>. There are similar symbols
GDK_DISABLE_DEPRECATED, GDK_PIXBUF_DISABLE_DEPRECATED and
G_DISABLE_DEPRECATED for GDK, GdkPixbuf and GLib.</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>