2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
5 <refentry id="glib-cross-compiling" revision="7 Aug 2018">
7 <refentrytitle>Cross-compiling the GLib package</refentrytitle>
8 <manvolnum>3</manvolnum>
9 <refmiscinfo>GLib Library</refmiscinfo>
13 <refname>Cross-compiling the GLib Package</refname>
15 How to cross-compile GLib
20 <title>Building the Library for a different architecture</title>
22 Cross-compilation is the process of compiling a program or
23 library on a different architecture or operating system then
24 it will be run upon. GLib is slightly more difficult to
25 cross-compile than many packages because much of GLib is
26 about hiding differences between different systems.
29 These notes cover things specific to cross-compiling GLib;
30 for general information about cross-compilation, see the
31 <ulink url="http://mesonbuild.com/Cross-compilation.html">meson</ulink>
35 GLib tries to detect as much information as possible about
36 the target system by compiling and linking programs without
37 actually running anything; however, some information GLib
38 needs is not available this way. This information needs
39 to be provided to meson via a ‘cross file’.
42 As an example of using a cross file, to cross compile for
43 the ‘MingW32’ Win64 runtime environment on a Linux system,
44 create a file <filename>cross_file.txt</filename> with the following
59 c = 'x86_64-w64-mingw32-gcc'
60 cpp = 'x86_64-w64-mingw32-g++'
61 ar = 'x86_64-w64-mingw32-ar'
62 strip = 'x86_64-w64-mingw32-strip'
63 pkgconfig = 'x86_64-w64-mingw32-pkg-config'
64 windres = 'x86_64-w64-mingw32-windres'
67 Then execute the following commands:
70 meson --cross_file cross_file.txt builddir
73 The complete list of cross properties follows. Most
74 of these won't need to be set in most cases.
77 <refsect1 id="cross-properties">
78 <title>Cross properties</title>
80 <title>have_[function]</title>
83 When meson checks if a function is supported, the test can be
84 overridden by setting the
85 <literal>have_<replaceable>function</replaceable></literal> property
86 to <constant>true</constant> or <constant>false</constant>.
87 For example <programlisting>Checking for function "alloca" : YES</programlisting>
88 can be overridden by setting <programlisting>have_alloca = false</programlisting>
92 <title>growing_stack=[true/false]</title>
95 Whether the stack grows up or down. Most places will want
96 <constant>false</constant>.
97 A few architectures, such as PA-RISC need <constant>true</constant>.
101 <title>have_strlcpy=[true/false]</title>
104 Whether you have <function>strlcpy()</function> that matches
105 OpenBSD. Defaults to <constant>false</constant>, which is safe,
106 since GLib uses a built-in version in that case.
110 <title>va_val_copy=[true/false]</title>
113 Whether <type>va_list</type> can be copied as a pointer. If set
114 to <constant>false</constant>, then <function>memcopy()</function>
115 will be used. Only matters if you don't have
116 <function>va_copy()</function> or <function>__va_copy()</function>.
117 (So, doesn't matter for GCC.)
118 Defaults to <constant>true</constant> which is slightly more common
119 than <constant>false</constant>.
123 <title>have_c99_vsnprintf=[true/false]</title>
126 Whether you have a <function>vsnprintf()</function> with C99
127 semantics. (C99 semantics means returning the number of bytes
128 that would have been written had the output buffer had enough
129 space.) Defaults to <constant>false</constant>.
133 <title>have_c99_snprintf=[true/false]</title>
136 Whether you have a <function>snprintf()</function> with C99
137 semantics. (C99 semantics means returning the number of bytes
138 that would have been written had the output buffer had enough
139 space.) Defaults to <constant>false</constant>.