building libtorrent for C.H.I.P.™

I recently bought a C.H.I.P. and naturally wanted to build libtorrent for it. I’m on a mac and chip runs arm, so first I needed to install the cross compiler toolchain. The target for chip is arm on linux, so the toolchain I’m looking for is “arm-linux-gnueabihf”.


It seems like a fair number of people online suggest using “gcc-arm-none-eabi”, presumably because that’s a package that’s easily available on homebrew. However, having a generic build, not for linux, means linux specifics won’t work. Specifically, the “-pthread” argument is not recognized by that variant of GCC.

There are old binaries for a linaro gcc cross compiler build for mac OS here. This installs all the gcc and binutils we need:

... etc ...

The tools we’re especially concerned with are arm-linux-gnueabihf-g++ (the compiler) and arm-linux-gnueabihf-ar (the archiver for making static libraries) and arm-linux-gnueabihf-ld (the linker). Let’s first check out the compiler:

$ arm-linux-gnueabihf-g++ --version
arm-linux-gnueabihf-g++ (crosstool-NG linaro-1.13.1-4.9-2014.05 - Linaro GCC 4.9-2014.05) 4.9.1 20140505 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO


Next we need to configure boost build to know about this version of gcc. It’s possible to configure toolsets per project, but I like to configure my toolsets user-wide. For this, you put the definition in ~/user-config.jam.

The rule for configuring a toolset in boost build is “using” and its synopsis is:

using toolset : version : compile-command : options ;

toolset: The toolset is called gcc.
version: To avoid clashing with the system compiler, we give this configuration of the toolset a unique name, “chip”. It will be referred to as “gcc-chip” on the b2 command line later.
compile-command: This is the command to run the compiler, “arm-linux-gnueabihf-g++”.
options: You need to specify which target-os and architecture this toolset builds for, you do this with:

<target-os>linux <architecture>arm

In this case I have an older version of GCC that doesn’t default to C++11, so I also need to specify:

<cxxflags>-std=c++11 <linkflags>-std=c++11

boost build will link via the compile command, but it will need to know which archiver to use to build static libraries/archives. You specify that like this:


Putting it all together you get this line in your ~/user-config.jam:

using gcc : chip : arm-linux-gnueabihf-g++ : <archiver>arm-linux-gnueabihf-ar
   <cxxflags>-std=c++11 <linkflags>-std=c++11 ;

Keep in mind that whitespace matters in jam. You need those spaces around “:” and “;”.

This configures a GCC compiler for the specified target operating system and architecture.

building libtorrent

To build libtorrent for this target, in the libtorrent example directory, run:

$ b2 gcc-chip -j4 link=static target-os=linux architecture=arm release

For a development build, you want to disable invariant checks, since they can be quite expensive, causing poor run-time performance:

$ b2 gcc-chip -j4 link=static target-os=linux architecture=arm invariant-checks=off

Leave a Reply