Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Update Windows build instructions #2383

Merged
merged 4 commits into from
Nov 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 25 additions & 41 deletions doc/build-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ Below are some notes on how to build Gridcoin for Windows.

The options known to work for building Gridcoin on Windows are:

* On Linux, using the [Mingw-w64](https://mingw-w64.org/doku.php) cross compiler tool chain. Ubuntu Bionic 18.04 is required
and is the platform used to build the Gridcoin Windows release binaries.
* On Windows, using [Windows
Subsystem for Linux (WSL)](https://docs.microsoft.com/windows/wsl/about) and the Mingw-w64 cross compiler tool chain.
* On Windows, using a native compiler tool chain such as [Visual Studio](https://www.visualstudio.com).
* On Linux, using the [Mingw-w64](https://www.mingw-w64.org/) cross compiler tool chain.
* On Windows, using [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/windows/wsl/about) and Mingw-w64.

Other options which may work, but which have not been extensively tested are (please contribute instructions):

Expand All @@ -18,35 +15,7 @@ Other options which may work, but which have not been extensively tested are (pl
Installing Windows Subsystem for Linux
---------------------------------------

With Windows 10, Microsoft has released a new feature named the [Windows
Subsystem for Linux (WSL)](https://docs.microsoft.com/windows/wsl/about). This
feature allows you to run a bash shell directly on Windows in an Ubuntu-based
environment. Within this environment you can cross compile for Windows without
the need for a separate Linux VM or server. Note that while WSL can be installed with
other Linux variants, such as OpenSUSE, the following instructions have only been
tested with Ubuntu.

This feature is not supported in versions of Windows prior to Windows 10 or on
Windows Server SKUs. In addition, it is available [only for 64-bit versions of
Windows](https://docs.microsoft.com/windows/wsl/install-win10).

Full instructions to install WSL are available on the above link.
To install WSL on Windows 10 with Fall Creators Update installed (version >= 16215.0) do the following:

1. Enable the Windows Subsystem for Linux feature
* Open the Windows Features dialog (`OptionalFeatures.exe`)
* Enable 'Windows Subsystem for Linux'
* Click 'OK' and restart if necessary
2. Install Ubuntu
* Open Microsoft Store and search for "Ubuntu 18.04" or use [this link](https://www.microsoft.com/store/productId/9N9TNGVNDL3Q)
* Click Install
3. Complete Installation
* Open a cmd prompt and type "Ubuntu1804"
* Create a new UNIX user account (this is a separate account from your Windows account)

After the bash shell is active, you can follow the instructions below, starting
with the "Cross-compilation" section. Compiling the 64-bit version is
recommended, but it is possible to compile the 32-bit version.
Follow the upstream installation instructions, available [here](https://docs.microsoft.com/windows/wsl/install-win10).

Cross-compilation for Ubuntu and Windows Subsystem for Linux
------------------------------------------------------------
Expand Down Expand Up @@ -80,9 +49,24 @@ The first step is to install the mingw-w64 cross-compilation tool chain:

sudo apt install g++-mingw-w64-x86-64

Ubuntu Bionic 18.04:
Next, set the default `mingw32 g++` compiler option to POSIX:

sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
```
sudo update-alternatives --config x86_64-w64-mingw32-g++
```

After running the above command, you should see output similar to that below.
Choose the option that ends with `posix`.

```
There are 2 choices for the alternative x86_64-w64-mingw32-g++ (providing /usr/bin/x86_64-w64-mingw32-g++).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/x86_64-w64-mingw32-g++-win32 60 auto mode
* 1 /usr/bin/x86_64-w64-mingw32-g++-posix 30 manual mode
2 /usr/bin/x86_64-w64-mingw32-g++-win32 60 manual mode
Press <enter> to keep the current choice[*], or type selection number:
```

Once the toolchain is installed the build steps are common:

Expand All @@ -102,9 +86,9 @@ Build using:
cd depends
make HOST=x86_64-w64-mingw32
cd ..
./autogen.sh # not required when building from tarball
./autogen.sh
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
make
make # use "-j N" for N parallel jobs
sudo bash -c "echo 1 > /proc/sys/fs/binfmt_misc/status" # Enable WSL support for Win32 applications.

## Building for 32-bit Windows
Expand All @@ -113,7 +97,7 @@ To build executables for Windows 32-bit, install the following dependencies:

sudo apt-get install g++-mingw-w64-i686 mingw-w64-i686-dev

For Ubuntu Xenial 16.04, Ubuntu Zesty 17.04 and Windows Subsystem for Linux:
Next, set the default `mingw32 g++` compiler option to POSIX:

sudo update-alternatives --config i686-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.

Expand All @@ -131,9 +115,9 @@ Then build using:
cd depends
make HOST=i686-w64-mingw32
cd ..
./autogen.sh # not required when building from tarball
./autogen.sh
CONFIG_SITE=$PWD/depends/i686-w64-mingw32/share/config.site ./configure --prefix=/
make
make # use "-j N" for N parallel jobs
sudo bash -c "echo 1 > /proc/sys/fs/binfmt_misc/status" # Enable WSL support for Win32 applications.

## Depends system
Expand Down