Merge branch 'tor-gitlab/mr/555'
[tor.git] / doc / building-tor-msvc.txt
blobdbc644d1720ce42a5e991f3f20993353b5e35149
1 Building Tor with MSVC.\r
2 =======================\r
3 \r
4 NOTE: This is not the preferred method for building Tor on windows: we use\r
5 mingw for our packages.\r
6 \r
7 Last updated 9 September 2014.\r
8 \r
9 \r
10 Requirements:\r
11 -------------\r
13  * Visual Studio 2010\r
14     https://go.microsoft.com/fwlink/?LinkId=323467\r
15  * CMake 2.8.12.2\r
16     https://www.cmake.org/download/\r
17  * Perl 5.16\r
18     https://www.activestate.com/activeperl/downloads\r
19  * Latest stable OpenSSL tarball\r
20     https://www.openssl.org/source/\r
21  * Latest stable zlib tarball\r
22     https://zlib.net/\r
23  * Latest stable libevent Libevent tarball\r
24     https://github.com/libevent/libevent/releases\r
26 Make sure you check signatures for all these packages.\r
28 Steps:\r
29 ------\r
31 Building OpenSSL from source as a shared library:\r
33  cd <openssl source dir>\r
34  perl Configure VC-WIN32\r
35  perl util\mkfiles.pl >MINFO\r
36  perl util\mk1mf.pl no-asm dll VC-WIN32 >32dll.mak\r
37  perl util\mkdef.pl 32 libeay > ms\libeay32.def\r
38  perl util\mkdef.pl 32 ssleay > ms\ssleay32.def\r
39  nmake -f 32dll.mak\r
41 Making OpenSSL final package:\r
43  Create <openssl final package dir>, I'd recommend using a name like <openssl\r
44  source dir>-vc10.\r
46  Copy the following directories and files to their respective locations\r
47   <openssl source dir>\inc32\openssl => <openssl final package dir>\include\openssl\r
48   <openssl source dir>\out32dll\libeay32.lib => <openssl final package dir>\lib\libeay32.lib\r
49   <openssl source dir>\out32dll\ssleay32.lib => <openssl final package dir>\lib\ssleay32.lib\r
50   <openssl source dir>\out32dll\libeay32.dll => <openssl final package dir>\bin\libeay32.dll\r
51   <openssl source dir>\out32dll\openssl.exe => <openssl final package dir>\bin\openssl.exe\r
52   <openssl source dir>\out32dll\ssleay32.dll => <openssl final package dir>\bin\ssleay32.dll\r
54 Building Zlib from source:\r
56  cd <zlib source dir>\r
57  nmake -f win32/Makefile.msc\r
59 Building libevent:\r
61  cd <libevent source dir>\r
62  mkdir build && cd build\r
63  SET OPENSSL_ROOT_DIR=<openssl final package dir>\r
64  cmake -G "NMake Makefiles" .. -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="/MT /Zi /O2 /Ob1 /D NDEBUG" -DZLIB_LIBRARY:FILEPATH="<zlib source dir>\zdll.lib" -DZLIB_INCLUDE_DIR:PATH="<zlib source dir>"\r
65  nmake event\r
67 Building Tor:\r
69  Create a dir above tor source dir named build-alpha and two subdirs include\r
70  and lib.\r
72  Your build tree should now be similar to this one:\r
73   * build-alpha\r
74     - include\r
75     - lib\r
76   * <libevent source dir>\r
77     - build\r
78     - cmake\r
79     - ...\r
80   * <openssl source dir>\r
81     - ...\r
82     - ms\r
83     - util\r
84     - ...\r
85   * <openssl final package dir>\r
86     - bin\r
87     - include\r
88     - lib\r
89   * <tor source dir>\r
90     - ...\r
91     - src\r
92     - ...\r
93   * <zlib source dir>\r
94     - ...\r
95     - win32\r
96     - ...\r
98  Copy the following dirs and files to the following locations:\r
99   <openssl final package dir>\include\openssl => build-alpha\include\openssl\r
100   <libevent source dir>\include => build-alpha\include\r
101   <libevent source dir>\WIN32-Code\nmake\event2 => build-alpha\include\event2\r
102   <zlib source dir>\z*.h => build-alpha\include\z*.h\r
104  Now copy the following files to the following locations and rename them\r
105  according new names:\r
107   <libevent source dir>\build\lib\event.lib => build-alpha\lib\libevent.lib\r
108   <openssl final package dir>\lib\libeay32.lib => build-alpha\lib\libcrypto.lib\r
109   <openssl final package dir>\lib\ssleay32.lib => build-alpha\lib\libssl.lib\r
110   <zlib source dir>\zdll.lib => build-alpha\lib\libz.lib\r
112  And we are now ready for the build process:\r
114   cd <tor source dir>\r
115   nmake -f Makefile.nmake\r
117  After the above process is completed there should be a tor.exe in <tor\r
118  source dir>\src\or\r
120  Copy tor.exe to desired location and also copy zlib1.dll, libeay32.dll and\r
121  ssleay32.dll from built zlib and openssl packages\r