User Tools

Site Tools


TOR Executabe for Windows

In a project I needed to have statically built tor.exe (single executable) for windows. Official tor expert bundle distribution has many dll files which is undesirable for my needs. So I compiled it under windows using mingw and msys for x86 architecture. Since it is a tedious job to compile all tor dependencies and tor, I put it here for good. Zip file includes only tor.exe, tor-gencert.exe and tor-resolve.exe as well. If you don't need tor-gencert.exe and tor-resolve.exe, you can delete them.

Download Links

How to Compile Tor using MinGW

Building TOR having a static executable is described below. If you are familiar with Linux shells, it is easier for you. Follow the instructions below. If you have any problem, do not hesitate to ask. I put lots of environment variables and compiler/linker flags to be on the safe side even if they are useless. Let me know if anything is unnecessary. If you do not need a static executable, just visit tor website and download tor expert bundle.

# written on a cold November day 2016
# these instructions are for x86 computers, for x64 you know what to do :)
# install msys2 from
# after installation, open msys2 console and install some useful packages (msys2.exe)
# visit wiki pages of msys2 for further information
pacman -Syuu
pacman -S msys/make msys/perl msys/tar
pacman -S mingw32/mingw-w64-i686-binutils msys/binutils
pacman -S mingw32/mingw-w64-i686-gcc
pacman -S mingw32/mingw-w64-i686-make
pacman -S msys/pkg-config mingw32/mingw-w64-i686-pkg-config
# change console to mingw32 console (mingw32.exe)
# download required libraries for build process (openssl,zlib,libevent)
# Currently I cannot compile tor with openssl version greater than 1.0.2j
mkdir openssl && mkdir libevent && mkdir zlib && mkdir tor
tar xzf openssl-1.0.2j.tar.gz -C openssl
tar xzf zlib-1.2.8.tar.gz -C zlib
tar xzf libevent-2.0.22-stable.tar.gz -C libevent
tar xzf tor- -C tor
# you may set these environment variables for compiling zlib
export INCLUDE_PATH="/mingw32/include:/mingw32/i686-w64-mingw32/include:$INCLUDE_PATH"
export LIBRARY_PATH="/mingw32/lib:/mingw32/i686-w64-mingw32/lib:$LIBRARY_PATH"
export BINARY_PATH="/mingw32/bin:/mingw32/i686-w64-mingw32/bin:$BINARY_PATH"
# compile zlib
cd ~/zlib/zlib-1.2.8
make -fwin32/Makefile.gcc
# compile libevent
cd ~/libevent/libevent-2.0.22-stable
./configure --prefix="$HOME/libevent/install" --enable-static --disable-shared
make install
# compile openssl (if you don't have a fast computer, this may take a long time)
# -static-libgcc flag may be redundant with -static but just in case.
cd ~/openssl/openssl-1.0.2j
LDFLAGS="-static -static-libgcc" ./Configure no-shared no-zlib no-asm --prefix="$HOME/openssl/install" -static mingw
make depend && make && make install
# now it is time to compile tor if everything is OK above
cd ~/tor/tor-
export LDFLAGS="-static -static-libgcc -L$HOME/openssl/install/lib -L$HOME/libevent/install/lib -L$HOME/zlib/zlib-1.2.8 -L/mingw32/lib -L/mingw32/i686-w64-mingw32/lib"
export CFLAGS="-I$HOME/openssl/install/include -I$HOME/zlib/zlib-1.2.8 -I$HOME/libevent/install/include"
export LIBRARY_PATH="$HOME/openssl/install/lib:$HOME/libevent/install/lib:$HOME/zlib/zlib-1.2.8:/mingw32/lib:/mingw32/i686-w64-mingw32/lib"
export INCLUDE_PATH="$HOME/openssl/install/include:$HOME/zlib/zlib-1.2.8:$HOME/libevent/install/include:/mingw32/include:/mingw32/i686-w64-mingw32/include"
export BINARY_PATH="/mingw32/bin:/mingw32/i686-w64-mingw32/bin"
export PKG_CONFIG_PATH="$HOME/openssl/install/lib/pkgconfig:$PKG_CONFIG_PATH"
# this is important if -lcrypt32 is omitted, you may get linker error
export LIBS="-lcrypt32"
./configure --disable-gcc-hardening --enable-static-tor --prefix="$HOME/tor/install" --with-libevent-dir="$HOME/libevent/install/lib" --with-openssl-dir="$HOME/openssl/install/lib" --with-zlib-dir="$HOME/zlib/zlib-1.2.8"
make install
# The configuration parameter "--disable-gcc-hardening" builds Tor without requiring
# the libssp-0.dll. If you build without this parameter then don't forget to copy
# libssp-0.dll from /mingw32/bin to the folder where tor.exe is located. libssp is
# a library for stack protection.


Sherif, 2016/11/11 04:32

Thanks. It would be really helpful if you could share how you did it.

Ozan HACIBEKIROGLU, 2016/11/13 19:53

Hello, I will write a tutorial within this week and share it. Please, follow this page.

Sherif, 2016/11/14 02:29

Looking forward to it. Thanks!

Ozan HACIBEKIROGLU, 2016/11/17 06:57

I have added build instructions, please check them and let me know if everything is OK

Enter your comment. Wiki syntax is allowed:
tor/tor_for_windows.txt · Last modified: 2016/11/17 06:52 by ozan