Skip to content

Commit

Permalink
New Windows build instructions using VS.
Browse files Browse the repository at this point in the history
  • Loading branch information
ambrop72 committed Dec 30, 2018
1 parent 7c63ea1 commit 842241e
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 86 deletions.
103 changes: 103 additions & 0 deletions BUILD-WINDOWS-VisualStudio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Windows build using Visual Studio

This document describes how to build on Windows using Visual Studio. Note that only
32-bit build has been tested and is described here.

## Prerequisites

### Visual Studio

You need Visual Studio 2017.

### CMake

You need CMake, it is best to get the latest version.

### OpenSSL

You don't need this if you only need tun2socks or udpgw (but only for the VPN software).

Install ActivePerl if not already.

Download and extract the OpenSSL source code.

Open a Visual Studio x86 native tools command prompt (found under Programs -> Visual
Studio 2017) and enter the OpenSSL source code directory. In this terminal, run the
following commands:

```
perl Configure VC-WIN32 no-asm --prefix=%cd%\install-dir
ms\do_ms
nmake -f ms\ntdll.mak install
```

### NSS

You don't need this if you only need tun2socks or udpgw (but only for the VPN software).

Install MozillaBuild (https://wiki.mozilla.org/MozillaBuild).

Download and extract the NSS source code that includes NSPR
(`nss-VERSION-with-nspr-VERSION.tar.gz`).

Copy the file `C:\mozilla-build\start-shell.bat` to
`C:\mozilla-build\start-shell-fixed.bat`, and in the latter file REMOVE the following
lines near the beginning:

```
SET INCLUDE=
SET LIB=
IF NOT DEFINED MOZ_NO_RESET_PATH (
SET PATH=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem
)
```

Open a Visual Studio x86 native tools command prompt. In this terminal, first run the
following command to enter the mozilla-build bash shell:

```
C:\mozilla-build\start-shell-fixed.bat
```

Enter the NSS source code directory and run the following commands:

```
make -C nss nss_build_all OS_TARGET=WINNT BUILD_OPT=1
cp -r dist/private/. dist/public/. dist/WINNT*.OBJ/include/
```

## Building BadVPN

Open a Visual Studio x86 native tools command prompt (found under Programs -> Visual
Studio 2017) and enter the BadVPN source code directory.

If you needed to build OpenSSL and NSS, then specify the paths to the builds of these
libraries by setting the `CMAKE_PREFIX_PATH` environment variable as shown below;
replace `<openssl-source-dir>` and `<nss-source-dir>` with the correct paths. For NSS,
check if the `.OBJ` directory name is correct, if not then adjust that as well.

```
set CMAKE_PREFIX_PATH=<openssl-source-dir>\install-dir;<nss-source-dir>\dist\WINNT6.2_OPT.OBJ
```

Run the commands shown below. If you only need tun2socks and udpgw then also add
the following parameters to first `cmake` command:
`-DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1 -DBUILD_UDPGW=1`.

```
mkdir build
cd build
cmake .. -G "Visual Studio 15 2017" -DCMAKE_INSTALL_PREFIX=%cd%\..\install-dir
cmake --build . --config Release --target install
```

If you did need OpenSSL and NSS, then copy the needed DLL so that the programs will
be able to find them. You can use the following commands to do this (while still in
the `build` directory):

```
copy <openssl-source-dir>\install-dir\bin\libeay32.dll ..\install-dir\bin\
copy <nss-source-dir>\dist\WINNT6.2_OPT.OBJ\lib\*.dll ..\install-dir\bin\
```

The build is now complete and is located in `<badvpn-source-dir>\install-dir`.
79 changes: 0 additions & 79 deletions BUILD-WINDOWS-old.txt

This file was deleted.

28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,31 @@ These connections are used for transferring network data (Ethernet frames), and
- Local peers inside a NAT can communicate directly
- Relaying as a fallback (needs configuration)

## Documentation

- [NCD] - Introduction to the NCD language.
- [badvpn] - General description of BadVPN and its features.
- [Examples] - Quick guide to setting up a working VPN.
- [badvpn_server], [badvpn_client] - Documentation of individual programs.

## Requirements

NCD only works on Linux. Tun2socks works on Linux and Windows. The P2P VPN works on Linux, Windows and FreeBSD (not tested often).

## Installation

The build system is based on CMake. On Linux, the following commands can be used to
build:

```
cd <badvpn-source-dir>
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=<install-dir>
make install
```

If you only need tun2socks or udpgw, then add the following arguments to the `cmake`
command: `-DBUILD_NOTHING_BY_DEFAULT=1 -DBUILD_TUN2SOCKS=1 -DBUILD_UDPGW=1`.
Otherwise (if you want the VPN software), you will first need to install the OpenSSL
and NSS libraries and make sure that CMake can find them.

Windows builds are not provided. You can build from source code using Visual Studio by
following the instructions in the file `BUILD-WINDOWS-VisualStudio.md`.

## License

The BSD 3-clause license as shown below applies to most of the code.
Expand Down

0 comments on commit 842241e

Please sign in to comment.