File: sec-headers-and-linking.html

package info (click to toggle)
gtkmm-documentation 4.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,772 kB
  • sloc: cpp: 15,541; javascript: 1,208; makefile: 1,080; python: 401; xml: 106; perl: 67; sh: 8
file content (105 lines) | stat: -rw-r--r-- 5,469 bytes parent folder | download
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="highlight.min.css">
<script src="highlight.min.js"></script><script>
      hljs.configure({languages: ['cpp']});
      hljs.highlightAll();
    </script><title>Headers and Linking</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="Programming with gtkmm 4">
<link rel="up" href="chapter-basics.html" title="Chapter 3. Basics">
<link rel="prev" href="chapter-basics.html" title="Chapter 3. Basics">
<link rel="next" href="sec-widgets-overview.html" title="Widgets">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Headers and Linking</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="chapter-basics.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center">Chapter 3. Basics</th>
<td width="20%" align="right"> <a accesskey="n" href="sec-widgets-overview.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-headers-and-linking"></a>Headers and Linking</h2></div></div></div>


<p>
Although we have shown the compilation command for the simple example, you really
should use the <a class="ulink" href="https://mesonbuild.com/" target="_top">Meson build system</a>.
The examples used in this book are included in the <span class="application">gtkmm-documentation</span>
package, with appropriate build files, so we won't show the build commands in future.
The <code class="filename">README</code> file in <span class="application">gtkmm-documentation</span>
describes how to build the examples.
</p>
<p>
To simplify compilation, we use <code class="literal">pkg-config</code>, which
is present in all (properly installed) <span class="application">gtkmm</span> installations. This
program 'knows' what compiler switches are needed to compile programs
that use <span class="application">gtkmm</span>. The <code class="literal">--cflags</code> option causes
<code class="literal">pkg-config</code> to output a list of include directories for the
compiler to look in; the <code class="literal">--libs</code> option requests the
list of libraries for the compiler to link with and the directories to
find them in. Try running it from your shell-prompt to see the results on your system.
</p>
<p>
However, this is even simpler when using the <code class="function">dependency()</code> function
in a <code class="filename">meson.build</code> file with Meson. For instance:
</p>
<pre class="programlisting"><code class="code">gtkmm_dep = dependency('gtkmm-4.0', version: '&gt;= 4.6.0')</code></pre>
<p>
This checks for the presence of gtkmm and defines <code class="literal">gtkmm_dep</code> for use
in your <code class="filename">meson.build</code> files. For instance:
</p>
<pre class="programlisting"><code class="code">exe_file = executable('my_program', 'my_source1.cc', 'my_source2.cc',
  dependencies: gtkmm_dep,
  win_subsystem: 'windows',
)</code></pre>
<p>gtkmm-4.0 is the name of the current stable API. There are older APIs called gtkmm-2.4
and gtkmm-3.0 which install in parallel when they are available. There are several
versions of gtkmm-2.4, such as gtkmm 2.10 and there are several versions of the gtkmm-3.0 API.
Note that the API name does not change for every version because that would be an incompatible
API and ABI break. There might be a future gtkmm-5.0 API which would install in parallel
with gtkmm-4.0 without affecting existing applications.
</p>
<p>If you start by experimenting with a small application that you plan to use just for yourself,
it's easier to start with a <code class="filename">meson.build</code> similar to the <code class="filename">meson.build</code> files
in the <a class="link" href="chapter-building-applications.html" title="Chapter 31. Building applications">Building applications</a> chapter.
</p>

<p>If you use the older Autotools build system, see also the GNU site. It has more
information about <a class="ulink" href="https://www.gnu.org/software/autoconf/" target="_top">autoconf</a>
and <a class="ulink" href="https://www.gnu.org/software/automake/" target="_top">automake</a>.
There are also some books describing Autotools: "GNU Autoconf, Automake, and Libtool"
by Gary Vaughan et al. and "Autotools, A Practitioner's Guide to GNU Autoconf,
Automake, and Libtool" by John Calcote.
</p>

</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="chapter-basics.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"><a accesskey="u" href="chapter-basics.html"><img src="icons/up.png" alt="Up"></a></td>
<td width="40%" align="right"> <a accesskey="n" href="sec-widgets-overview.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 3. Basics </td>
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="icons/home.png" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Widgets</td>
</tr>
</table>
</div>
</body>
</html>