BadVPN – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 # Windows build using Visual Studio
2  
3 This document describes how to build on Windows using Visual Studio. Note that only
4 32-bit build has been tested and is described here.
5  
6 ## Prerequisites
7  
8 ### Visual Studio
9  
10 You need Visual Studio 2017.
11  
12 ### CMake
13  
14 You need CMake, it is best to get the latest version.
15  
16 ### OpenSSL
17  
18 You don't need this if you only need tun2socks or udpgw (but only for the VPN software).
19  
20 Install ActivePerl if not already.
21  
22 Download and extract the OpenSSL source code.
23  
24 Open a Visual Studio x86 native tools command prompt (found under Programs -> Visual
25 Studio 2017) and enter the OpenSSL source code directory. In this terminal, run the
26 following commands:
27  
28 ```
29 perl Configure VC-WIN32 no-asm --prefix=%cd%\install-dir
30 ms\do_ms
31 nmake -f ms\ntdll.mak install
32 ```
33  
34 ### NSS
35  
36 You don't need this if you only need tun2socks or udpgw (but only for the VPN software).
37  
38 Install MozillaBuild (https://wiki.mozilla.org/MozillaBuild).
39  
40 Download and extract the NSS source code that includes NSPR
41 (`nss-VERSION-with-nspr-VERSION.tar.gz`).
42  
43 Copy the file `C:\mozilla-build\start-shell.bat` to
44 `C:\mozilla-build\start-shell-fixed.bat`, and in the latter file REMOVE the following
45 lines near the beginning:
46  
47 ```
48 SET INCLUDE=
49 SET LIB=
50 IF NOT DEFINED MOZ_NO_RESET_PATH (
51 SET PATH=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem
52 )
53 ```
54  
55 Open a Visual Studio x86 native tools command prompt. In this terminal, first run the
56 following command to enter the mozilla-build bash shell:
57  
58 ```
59 C:\mozilla-build\start-shell-fixed.bat
60 ```
61  
62 Enter the NSS source code directory and run the following commands:
63  
64 ```
65 make -C nss nss_build_all OS_TARGET=WINNT BUILD_OPT=1
66 cp -r dist/private/. dist/public/. dist/WINNT*.OBJ/include/
67 ```
68  
69 ## Building BadVPN
70  
71 Open a Visual Studio x86 native tools command prompt (found under Programs -> Visual
72 Studio 2017) and enter the BadVPN source code directory.
73  
74 If you needed to build OpenSSL and NSS, then specify the paths to the builds of these
75 libraries by setting the `CMAKE_PREFIX_PATH` environment variable as shown below;
76 replace `<openssl-source-dir>` and `<nss-source-dir>` with the correct paths. For NSS,
77 check if the `.OBJ` directory name is correct, if not then adjust that as well.
78  
79 ```
80 set CMAKE_PREFIX_PATH=<openssl-source-dir>\install-dir;<nss-source-dir>\dist\WINNT6.2_OPT.OBJ
81 ```
82  
83 Run the commands shown below. If you only need tun2socks and udpgw then also add
84 the following parameters to first `cmake` command:
85 `-DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1 -DBUILD_UDPGW=1`.
86  
87 ```
88 mkdir build
89 cd build
90 cmake .. -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX=%cd%\..\install-dir
91 cmake --build . --config Release --target install
92 ```
93  
94 If you did need OpenSSL and NSS, then copy the needed DLL so that the programs will
95 be able to find them. You can use the following commands to do this (while still in
96 the `build` directory):
97  
98 ```
99 copy <openssl-source-dir>\install-dir\bin\libeay32.dll ..\install-dir\bin\
100 copy <nss-source-dir>\dist\WINNT6.2_OPT.OBJ\lib\*.dll ..\install-dir\bin\
101 ```
102  
103 The build is now complete and is located in `<badvpn-source-dir>\install-dir`.