Skip to content

Cross compile syslog ng

Máté FARKAS edited this page Oct 6, 2017 · 4 revisions

This tutorial was originally created by @bazsi.


Here's a description on how I've cross-compiled syslog-ng to arm64.

Toolchain

I've used the docker based cross-compile toolchain from here: https://github.com/dockcross/dockcross

You'll need docker on your build machine, see https://docker.com for intallation instructions.

To use that, you'll only need to launch a docker command line and it would automatically fetch the image from the docker registry. I've used linux-arm64 as an example, but I guess the others would also work.

Sources

You will need the release tarball. Please note that you can download both the release tarball and a git snaphot from github, but you'll definitely need the release tarball if you don't have all the build requirements installed (automake, libtool and friends).

I've used https://github.com/balabit/syslog-ng/releases/download/syslog-ng-3.12.1/syslog-ng-3.12.1.tar.gz

Get the dockcross helper

$ docker run --rm dockcross/linux-arm64 > dockcross
$ chmod +x dockcross

Launch the cross-compile environment

Extract the sources (e.g. tar xvfz syslog-ng-3.12.1.tar.gz) into a directory, cd into it and launch the environment:

$ dockcross bash

This will give you a shell within the container, with a /work directory containing the sources.

Install dependencies

# this one fixes an issue within the container, "cpp" is unfortunately only
# available with a versioned binary, which the configure script does not find.
$ sudo ln -s /usr/bin/aarch64-linux-gnu-cpp-4.9
/usr/bin/aarch64-linux-gnu-cpp

# this is the minimal set of dependencies to compile syslog-ng, you might need
# others the bundled sources should however give you a pretty ok feature set
$ sudo apt-get install libglib2.0-dev:arm64 pkg-config:arm64

Build

$ mkdir build
$ cd build
$ /work/configure --host aarch64-linux-gnu
# <long configure output>
$ make

Install

$ make install DESTDIR=/work/build/install

The resulting set of binaries you will find in /work/build/install, as if it was installed in the root system (e.g. /usr/local/bin/syslog-ng would become /work/build/install/usr/local/bin/syslog-ng)

Collect binaries

Exit the docker container, your build products will be in the build subdirectory of your source tree, with build/install containing the final binaries.

bazsi@bzorp:~/src/syslog-ng-3.12.1/build/install$ file
usr/local/sbin/syslog-ng
usr/local/sbin/syslog-ng: ELF 64-bit LSB executable, ARM aarch64, version 1
(SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for
GNU/Linux 3.7.0, BuildID[sha1]=424c7a32112262725b267e6043c25bd40d039568,
not stripped

I hope this helps.

Clone this wiki locally