Compile Tor Statically

Make a temporary directory to work in:

1
2
mkdir /tmp/static_tor
cd /tmp/static_tor

Make a directory that we will install the static libraries in:

1
mkdir install

Download and compile the dependencies (libevent, openssl and zlib):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
tar xf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --disable-shared --enable-static --with-pic --prefix=/tmp/static_tor/install
make -j4
make install
cd ..
wget https://www.openssl.org/source/openssl-1.0.1r.tar.gz
tar xf openssl-1.0.1r.tar.gz
cd openssl-1.0.1r
./config no-shared no-dso --prefix=/tmp/static_tor/install
make -j4
make install
cd ..
wget http://zlib.net/zlib-1.2.8.tar.gz
tar xf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --static --prefix=/tmp/static_tor/install
make -j4
make install
cd ..

Clone the Tor source and compile it:

1
2
3
4
5
6
git clone https://git.torproject.org/tor.git
cd tor
git co tor-0.2.7.6
./autogen.sh
./configure --disable-asciidoc --enable-static-tor --with-libevent-dir=/tmp/static_tor/install --with-openssl-dir=/tmp/static_tor/install --with-zlib-dir=/tmp/static_tor/install
make -j4

The Tor binary should be statically compiled:

1
./src/or/tor --version