(this guide is probably out of date)

I have recently successfully built i2pd for the raspberry pi using a cross compiler on Ubuntu 16.04 LTS for amd64. So far i2pd has an uptime of over a week with no crashes or memory leaks running a small irc server. There are still a few things i2pd could do better, specifically more documentation but I digress.

Building

First off if you don't have git install it along with the basic compiler stuffs.

1
$ sudo apt install git build-essential

To build a static i2pd for raspberry pi you'll need to build an environment with all the i2pd dependencies. We'll use ubuntu's gcc arm cross compiler for this.

1
$ sudo apt install g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf

We don't want to mix the libraries we are going to build with our system libraries as they are for ARM not x86 so we'll make a separate directory to hold them.

1
2
$ export RPI="~/rpi"
$ mkdir -p "$RPI/src"

Optionally you can have $RPI defined in .bashrc so you don't have to export it every time you want to build:

$ echo 'export RPI="~/rpi"' >> ~/.bashrc

Now on to building all the dependencies for i2pd (from source of course)

Building Zlib

We'll start with the simplest dependency, zlib

Obtain and unpack zlib...

1
2
3
$ cd $RPI/src
$ wget http://zlib.net/zlib-1.2.8.tar.gz
$ tar -xzf zlib-1.2.8.tar.gz

... then build and install.

1
2
3
$ cd zlib-1.2.8
$ CHOST=arm-linux-gnueabihf ./configure --prefix=$RPI --static
$ make && make install

If all is well continue to the next step.

Building libressl

For this static build I'll be using libressl instead of openssl for "security" reasons.

Grab the source...

1
2
3
$ cd $RPI/src
$ git clone https://github.com/libressl-portable/portable libressl
$ cd libressl

... then build and install.

1
2
3
$ ./autogen.sh
$ ./configure --host=arm-linux-gnueabihf --prefix=$RPI
$ make && make install

Building Boost

Here's the dependency that has a little gotcha, boost.

Grab the source...

1
2
3
4
$ cd $RPI/src
$ wget https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz
$ tar -xzf boost_1_61_0.tar.gz
$ cd boost_1_61_0

Set up the build with just libraries we need...

1
$ ./bootstrap.sh --prefix=$RPI --without-icu --without-libraries='python,mpi,log,wave,graph,math,context,coroutine,coroutine2,iostreams'

Now for the gotcha, you want to cross compile to arm so you're going to have to patch project-config.jam.

1
2
$ sed 's/using\ gcc/using\ gcc\ \:\ arm\ \:\ arm-linux-gnueabihf-g\+\+/' < project-config.jam > project-config.jam.new
$ mv project-config.jam.new project-config.jam

... now build and install, there may be errors but that's (probably) okay.

1
$ ./b2 -toolset=arm install

Building i2pd

Finally we have all the dependencies for i2pd built, now build the daemon itself.

Grab the source...

1
2
3
$ cd $RPI/src
$ git clone https://github.com/purplei2p/i2pd
$ cd i2pd

... and compile

1
$ make CXX=arm-linux-gnueabihf-g++ LIBDIR="$RPI/lib" USE_AESNI=no USE_STATIC=yes INCFLAGS="-I$RPI/include"

If all goes right you'll get a statically compiled i2pd that runs on the raspberry pi.

Optionally you can strip the debugging symbols from the static binary with arm-linux-gnueabihf-strip i2pd

Copy to your rpi, run it as a non root user and enjoy.

If any steps don't work please feel free to contact me on twitter or via email


Update:

My static builds for rpi can be found here


Posted at by Jeff     Tags: i2p, i2pd, tutorial