5 Before you can start compiling tinc from a fresh git clone, you have to install
6 the very latest versions of the following packages:
8 - `meson` or `muon` (read below)
10 - `pkgconf` or `pkg-config`
11 - `GCC` or `Clang` (any version with C11 support, although older versions might
13 - `OpenSSL`\* (1.1.0+) or `LibreSSL` or `libgcrypt` (not needed if legacy
18 If you're on a constrained system that doesn't have (or cannot run) Python, you
19 can try building tinc with [muon][muon], which is a pure C reimplementation of
20 the same idea. Please note that `meson` is considered to be the main way of
21 building tinc, and `muon` is supported on a best-effort basis.
23 [muon]: https://git.sr.ht/~lattis/muon
27 Plus a few optional dependencies. Support for them will be enabled if they're
30 - `ncurses` or `PDCurses`
36 If packages marked by `*` are not available, tinc will fall back to its own
37 vendored copies. This behavior can be disabled by setting the appropriate meson
40 To build `info` documentation you'll also need these packages:
42 - `texinfo` or `makeinfo`
44 You might also need some additional command-line utilities to be able to run the
45 integration test suite:
55 Depending on the distribution, one of the following commands can be used to install all dependencies:
56 - Arch Linux: `sudo pacman --needed --sync base-devel meson ninja pkg-config openssl ncurses readline zlib lzo lz4 texinfo diffutils procps socat openbsd-netcat`
57 - Debian: `sudo apt install meson ninja-build pkg-config build-essential libssl-dev libncurses-dev libreadline-dev zlib1g-dev liblzo2-dev liblz4-dev texinfo diffutils procps socat netcat-openbsd`
58 - Alpine Linux: `doas apk add meson ninja pkgconf build-base linux-headers openssl-dev ncurses-dev readline-dev zlib-dev lzo-dev lz4-dev texinfo diffutils procps-ng socat netcat-openbsd`
59 - Fedora: `sudo dnf install meson ninja-build pkgconf-pkg-config @development-tools openssl-devel ncurses-devel readline-devel zlib-devel lzo-devel lz4-devel texinfo diffutils procps-ng socat netcat`
63 You can build tinc using either the native [Windows SDK][sdk-ms] (which comes
64 with Visual Studio), or with the Unix-like [msys2 environment][sdk-msys2].
65 Install either one of them, plus the latest version of [meson][meson-release].
67 If you prefer the native SDK, you might want to work on tinc (or build it) under
68 Visual Studio. To do so, follow [these instructions][meson-vs].
70 By default, tinc produces a static Windows build, so you don't need to install
71 anything in order to _run_ the compiled binaries.
73 [sdk-ms]: https://visualstudio.com/
74 [sdk-msys2]: https://msys2.org/
75 [meson-release]: https://github.com/mesonbuild/meson/releases
76 [meson-vs]: https://mesonbuild.com/Using-with-Visual-Studio.html
78 # Building from source
84 Tinc's functionality can vary greatly depending on how you configure it. Have a
85 look at the available options in [`meson_options.txt`](meson_options.txt), or
92 First you need to create a build directory. If you want the default experience,
99 or with configuration options (your shell can probably autocomplete them on
103 meson setup builddir -Dprefix=/usr/local -Dbuildtype=release
106 (For autotools users: this is a rough equivalent of
107 `autoreconf -fsi && ./configure --prefix=/usr/local --with-foobar`).
109 This creates a build directory (named `builddir`) with build type set to
110 `release` (which enables compiler optimizations) and path prefix set to
113 Pass any additional options in the same way. Typically, this is not needed: tinc
114 will autodetect available libraries and adjust its functionality accordingly.
116 If you'd like to reconfigure the project after running `setup`, you can either
117 remove the build directory and start anew, or use:
120 meson configure builddir -Dlzo=disabled -Dlz4=enabled
125 You then need to build the project:
128 meson compile -C builddir
131 (For autotools users: this is an equivalent of `make -j$(nproc)`).
135 You might want to run the test suite to ensure tinc is working correctly:
138 meson test -C builddir
141 (For autotools users: this is an equivalent of `make -j$(nproc) test`).
145 To install tinc to your system, run:
148 meson install -C builddir
151 (For autotools users: this is an equivalent of `make install`).
153 Please be aware that this is not the best method of installing software because
154 it will not be tracked by your operating system's package manager. You should
155 use packages provided by your operating system, or build your own (this is a
156 large and complicated topic which is out of the scope of this document).
160 To uninstall tinc, run:
163 ninja -C builddir uninstall
166 (For autotools users: this is an equivalent of `make uninstall`).
172 Cross-compilation is easy to do on Debian or its derivatives. Set `$HOST` to
173 your target architecture and install the cross-compilation toolchain and `-dev`
174 versions of all libraries you'd like to link:
178 dpkg --add-architecture $HOST
180 apt install -y crossbuild-essential-$HOST zlib1g-dev:$HOST …
183 If you'd like to run tests on emulated hardware, install `qemu-user`:
186 apt install -y qemu-user
187 update-binfmts --enable
190 Set two environment variables: the C compiler, and pkg-config, and then proceed
194 export CC=arm-linux-gnueabihf-gcc
195 export PKG_CONFIG=arm-linux-gnueabihf-pkg-config
196 meson setup build --cross-file /dev/null
199 Or put the names into a [cross file][cross] and pass it to meson:
202 cat >cross-armhf <<EOF
204 c = 'arm-linux-gnueabihf-gcc'
205 pkgconfig = 'arm-linux-gnueabihf-pkg-config'
208 meson setup build --cross-file cross-armhf
211 [cross]: https://mesonbuild.com/Cross-compilation.html
215 Install cross-compilation toolchain:
218 apt install -y mingw-w64 mingw-w64-tools
221 tinc will use its own vendored libraries, so you don't need to install or build
224 Prepare the [cross file][cross] to let meson know you're building binaries for a
225 different operating system. Take a look at the [file](.ci/cross/windows/amd64)
226 used by CI for an example, or refer to examples provided by the meson project:
227 [x86][mingw32],[x86_64][mingw64].
229 Then build as usual. Because Windows binaries are built with static linkage by
230 default, you might want to enable link-time optimization. It is much slower than
231 building without LTO, but produces binaries that are 80%+ smaller:
234 meson setup build -Dbuildtype=release -Db_lto=true --cross-file cross-windows
238 [mingw64]: https://github.com/mesonbuild/meson/blob/master/cross/linux-mingw-w64-64bit.txt
239 [mingw32]: https://github.com/mesonbuild/meson/blob/master/cross/linux-mingw-w64-32bit.txt
243 First you need to install [Android NDK][ndk].
245 [ndk]: https://developer.android.com/studio/projects/install-ndk
247 Prepare a [cross file][cross]. Here's a working example for reference:
257 c = 'aarch64-linux-android24-clang'
263 export ANDROID_NDK_ROOT=/tmp/ndk/android-ndk-r24
264 export PATH=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
265 meson setup android-aarch64 -Dcrypto=nolegacy --cross-file android
266 ninja -C android-aarch64
271 The same instructions should work for iOS. Refer to this [cross file][ios] for
274 [ios]: https://github.com/mesonbuild/meson/blob/master/cross/iphone.txt