Tor.exe cross compile for windows x86

Hello,

I need to cross compile from linux host to windows x86 (i586 / i686) target.
I tried to do it following this tutorial:

After few attempts (I wont describe the minor issues like apt build-dep failed and I was forced to download latest version sources manually/git) I’ve got executables successfully built by i686-w64-mingw32-gcc.

But here is the problem. As one may know, Windows executable PE header contains two important fields: Major OS version and Major subsystem version. I got the executable with 4.0 that must run under Windows XP / Server 2003 / Windows CE. Unfortnately, it does not. First problem is that bcrypt not found (BCryptGenRandom called by openssl, rand_win.c and probably libevent, util.h:838) and it’s impossible to copy this library from Windows 7 as it was build for 6.1 minium OS version. Second problem is incompatible functions AcquireSRWLockExclusive and similar calls in openssl, libevent and tor itself.

I’ve compared different builds of TOR (mainly from browser bundles) that I have. There is a tor browser bundle 5.0.6 from 2016 that I’ve used under Server 2003, but now it can not connect to the Tor network for unknown reason. The binary is fully compatible, the size is 2.4 Mb, there are libevent-2-0-5, zlib1 and openssl aside as dynamic link libraries.
There is a Tor.exe x86 from browser bundle 12.5.5 (7.5 Mb) possibly built by one of the latest Visual Studio and requires VC++ redistributable packages (api-ms-win-ctr-.dll) with static build of openssl inside, but it does not run as the OS version is set to 6.0.

I see an obvious solution to compile tor using shared (external dll) libraries openssl, zlib, libevent, borrowed from previous version browser bundles (or any other sources, for example I have openssl libraries on my Windows that are used by various software).

I tried to replace --enable-static-openssl with --enable-dynamic-openssl or remove this option but result is the same - static bilt binary off 11 Mb.
I would appreciate some manual how to build TOR with usage of external libraries under Linux (mingw).
Alternatively, any manual how to buld working TOR binary with Visual Studio 2010 (not later!) compatible with Windows v. 5 (XP) and later.

Also, if somebody have the information on why old tor.exe binary that was installed and worked 2-3 years ago can not connect to the network now (new can, so it’s not a censorship issue) or which version is the latest WinXP-compatible tor.exe binary. As for bundle, it is 7.5.6 (next 8.x already fails).

Thank you.

1 Like

To make it work, you need to revert changes from these two commits:
https://gitlab.torproject.org/tpo/core/tor/-/commit/f3b9be4422a08b6066bdb93874a5023e7c11ce9e
https://gitlab.torproject.org/tpo/core/tor/-/commit/877dbfc0561dfc5297cf446fe653cc3095d20b46

I chose slightly different route:
Downloaded MSYS2 from here:
https://web.archive.org/web/20220115133918/https://repo.msys2.org/distrib/i686/msys2-i686-20160205.exe
And then started hunt for needed packages all over the Internet.

What is needed to be found

autoconf-2.69-3-any.pkg.tar.xz
automake-wrapper-10-1-any.pkg.tar.xz
automake1.10-1.10.3-3-any.pkg.tar.xz
automake1.11-1.11.6-3-any.pkg.tar.xz
automake1.12-1.12.6-3-any.pkg.tar.xz
automake1.13-1.13.4-4-any.pkg.tar.xz
automake1.14-1.14.1-3-any.pkg.tar.xz
automake1.15-1.15-2-any.pkg.tar.xz
automake1.6-1.6.3-2-any.pkg.tar.xz
automake1.7-1.7.9-2-any.pkg.tar.xz
automake1.8-1.8.5-3-any.pkg.tar.xz
automake1.9-1.9.6-2-any.pkg.tar.xz
db-5.3.28-2-i686.pkg.tar.xz
diffutils-3.3-3-i686.pkg.tar.xz
gdbm-1.11-3-i686.pkg.tar.xz
libgdbm-1.11-3-i686.pkg.tar.xz
make-4.1-4-i686.pkg.tar.xz
mingw-w64-i686-binutils-2.25.1-1-any.pkg.tar.xz
mingw-w64-i686-bzip2-1.0.6-4-any.pkg.tar.xz
mingw-w64-i686-crt-git-5.0.0.4609.566d621-1-any.pkg.tar.xz
mingw-w64-i686-gcc-5.3.0-1-any.pkg.tar.xz
mingw-w64-i686-gcc-libs-5.3.0-1-any.pkg.tar.xz
mingw-w64-i686-gmp-6.1.0-1-any.pkg.tar.xz
mingw-w64-i686-headers-git-5.0.0.4609.566d621-1-any.pkg.tar.xz
mingw-w64-i686-isl-0.15-1-any.pkg.tar.xz
mingw-w64-i686-libevent-2.0.22-2-any.pkg.tar.xz
mingw-w64-i686-libiconv-1.14-5-any.pkg.tar.xz
mingw-w64-i686-libwinpthread-git-5.0.0.4573.628fdbf-1-any.pkg.tar.xz
mingw-w64-i686-mpc-1.0.3-2-any.pkg.tar.xz
mingw-w64-i686-mpfr-3.1.3.p0-2-any.pkg.tar.xz
mingw-w64-i686-openssl-1.0.2.e-1-any.pkg.tar.xz
mingw-w64-i686-windows-default-manifest-6.4-2-any.pkg.tar.xz
mingw-w64-i686-winpthreads-git-5.0.0.4573.628fdbf-1-any.pkg.tar.xz
mingw-w64-i686-zlib-1.2.8-9-any.pkg.tar.xz
perl-5.22.0-2-i686.pkg.tar.xz

Not very secure method, right. But it fits well enough with security level of Windows XP.

This is the result. Probably the only available right now XP binary for 0.4.8.9:
tor_0.4.8.9_xp.7z