This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
tor:tor_for_windows [2016/11/15 14:20] ozan |
tor:tor_for_windows [2016/11/17 06:52] (current) ozan |
||
---|---|---|---|
Line 8: | Line 8: | ||
{{:tor:tor_static-v0.2.7.6.zip|}} | {{:tor:tor_static-v0.2.7.6.zip|}} | ||
- | {{tag>tor expert_bundle windows mingw msys}} | + | |
+ | ==== 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. | ||
+ | |||
+ | <code bash tor_build_instructions.txt> | ||
+ | # written on a cold November day 2016 | ||
+ | # these instructions are for x86 computers, for x64 you know what to do :) | ||
+ | # install msys2 from http://msys2.github.io/ | ||
+ | # 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 | ||
+ | wget https://www.openssl.org/source/openssl-1.0.2j.tar.gz | ||
+ | wget http://zlib.net/zlib-1.2.8.tar.gz | ||
+ | wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz | ||
+ | wget https://www.torproject.org/dist/tor-0.2.8.9.tar.gz | ||
+ | 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-0.2.8.9.tar.gz -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 | ||
+ | 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-0.2.8.9 | ||
+ | |||
+ | 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 | ||
+ | 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. | ||
+ | </code> | ||
+ | |||
+ | |||
+ | {{tag>tor expert_bundle windows mingw msys2 msys}} | ||
~~DISCUSSION~~ | ~~DISCUSSION~~ |