Helpers to build Tor statically
MIT License
This project helps compile Tor into a static lib for use in other projects.
The dependencies are in this repository as submodules so this repository needs to be cloned with --recursive
. The
submodules are:
OpenSSL_1_1_1w
release-2.1.12-stable
v1.3.1
v5.6.2
tor-0.4.8.12
Many many bugs and quirks were hit while deriving these steps. Also many other repos, mailing lists, etc were leveraged to get some of the pieces right. They are not listed here for brevity reasons.
Note: Other versions of Tor may be available via tags (for current or previous versions) and branches (for future versions)
All platforms need Go installed and on the PATH.
Need:
sudo apt-get install build-essential
)sudo apt-get install libtool
)sudo apt-get install autopoint
)Need:
brew install go
)brew install libtool
)brew install automake
)brew install gettext
)
/usr/local/opt/gettext/bin
. Use -autopoint-path
to change it.brew install po4a
)Tor is not really designed to work well with MSVC so we use MinGW instead. In order to compile the dependencies, Msys2 + MinGW should be installed.
Download and install the latest MSYS2 64-bit that uses the MinGW-w64
toolchains. Once
installed, open the "MSYS MinGW 64-bit" shell link that was created. Once in the shell, run:
pacman -Syuu
Terminate and restart the shell if asked. Rerun this command as many times as needed until it reports that everything is up to date. Then in the same mingw-64 shell, run:
pacman -Sy --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain \
git subversion mercurial libtool automake autoconf automake-wrapper \
mingw-w64-i686-cmake mingw-w64-x86_64-cmake
This will install all the tools needed for building and will take a while. Once complete, MinGW is now setup to build the dependencies.
In the cloned directory, run:
go run build.go build-all
This will take a long time. Pieces can be built individually by changing the command from build-all
to
build-<folder>
. To clean, run either clean-all
or clean-<folder>
. To see the output of all the commands as they
are being run, add -verbose
before the command.
Once the libs have been compiled, they can be used to link with your program. Due to recent refactorings within the Tor source, the libraries are not listed here but instead listed when executing:
go run build.go show-libs
This lists directories (relative, prefixed with -L
) followed by lib names (file sans lib
prefix and sans .a
extension, prefixed with -l
) as might be used in ld
.
The OS-specific system libs that have to be referenced (i.e. -l<libname>
) are:
m
ws2_32
, crypt32
, gdi32
, iphlpapi
, and shlwapi
The OS-specific system libs that have to be explicitly statically linked (i.e. -Wl,-Bstatic -l<libname>
) are:
pthread