Changeset View
Changeset View
Standalone View
Standalone View
doc/build-windows.md
WINDOWS BUILD NOTES | WINDOWS BUILD NOTES | ||||
==================== | ==================== | ||||
Below are some notes on how to build Bitcoin ABC for Windows. | Below are some notes on how to build Bitcoin ABC for Windows. | ||||
The options known to work for building Bitcoin ABC on Windows are: | The options known to work for building Bitcoin ABC on Windows are: | ||||
* On Linux, using the [Mingw-w64](https://mingw-w64.org/doku.php) cross compiler tool chain. Ubuntu Trusty 14.04 is recommended | * On Linux, using the [Mingw-w64](https://mingw-w64.org/doku.php) cross compiler tool chain. Debian Buster is recommended | ||||
and is the platform used to build the Bitcoin ABC Windows release binaries. | and is the platform used to build the Bitcoin ABC Windows release binaries. | ||||
* On Windows, using [Windows | * On Windows, using [Windows | ||||
Subsystem for Linux (WSL)](https://msdn.microsoft.com/commandline/wsl/about) and the Mingw-w64 cross compiler tool chain. | Subsystem for Linux (WSL)](https://msdn.microsoft.com/commandline/wsl/about) and the Mingw-w64 cross compiler tool chain. | ||||
Other options which may work, but which have not been extensively tested are (please contribute instructions): | Other options which may work, but which have not been extensively tested are (please contribute instructions): | ||||
* On Windows, using a POSIX compatibility layer application such as [cygwin](http://www.cygwin.com/) or [msys2](http://www.msys2.org/). | * On Windows, using a POSIX compatibility layer application such as [cygwin](http://www.cygwin.com/) or [msys2](http://www.msys2.org/). | ||||
* On Windows, using a native compiler tool chain such as [Visual Studio](https://www.visualstudio.com). | * On Windows, using a native compiler tool chain such as [Visual Studio](https://www.visualstudio.com). | ||||
In any case please make sure that the compiler supports C++14. | In any case please make sure that the compiler supports C++14. | ||||
Installing Windows Subsystem for Linux | Installing Windows Subsystem for Linux | ||||
--------------------------------------- | --------------------------------------- | ||||
With Windows 10, Microsoft has released a new feature named the [Windows | With Windows 10, Microsoft has released a new feature named the [Windows | ||||
Subsystem for Linux (WSL)](https://msdn.microsoft.com/commandline/wsl/about). This | Subsystem for Linux (WSL)](https://msdn.microsoft.com/commandline/wsl/about). This | ||||
feature allows you to run a bash shell directly on Windows in an Ubuntu-based | 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 | 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 | 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 | other Linux variants, such as OpenSUSE, the following instructions have only been | ||||
tested with Ubuntu. | tested with Ubuntu Bionic. | ||||
This feature is not supported in versions of Windows prior to Windows 10 or on | 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 Server SKUs. In addition, it is available [only for 64-bit versions of | ||||
Windows](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide). | Windows](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide). | ||||
Full instructions to install WSL are available on the above link. | 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: | To install WSL on Windows 10 with Fall Creators Update installed (version >= 16215.0) do the following: | ||||
Show All 10 Lines | |||||
After the bash shell is active, you can follow the instructions below, starting | After the bash shell is active, you can follow the instructions below, starting | ||||
with the "Cross-compilation" section. Compiling the 64-bit version is | with the "Cross-compilation" section. Compiling the 64-bit version is | ||||
recommended, but it is possible to compile the 32-bit version. | recommended, but it is possible to compile the 32-bit version. | ||||
Cross-compilation for Ubuntu and Windows Subsystem for Linux | Cross-compilation for Ubuntu and Windows Subsystem for Linux | ||||
------------------------------------------------------------ | ------------------------------------------------------------ | ||||
At the time of writing the Windows Subsystem for Linux installs Ubuntu Xenial 16.04. The Mingw-w64 package | At the time of writing the Windows Subsystem for Linux installs Ubuntu Bionic 18.04. | ||||
for Ubuntu Xenial does not produce working executables for some of the Bitcoin ABC applications. | |||||
It is possible to build on Ubuntu Xenial by installing the cross compiler packages from Ubuntu Artful, see the steps below. | |||||
Building on Ubuntu Artful 17.10 has been verified to work. | |||||
The steps below can be performed on Ubuntu (including in a VM) or WSL. The depends system | The steps below can be performed on Ubuntu (including in a VM) or WSL. The depends system | ||||
will also work on other Linux distributions, however the commands for | will also work on other Linux distributions, however the commands for | ||||
installing the toolchain will be different. | installing the toolchain will be different. | ||||
First, install the general dependencies: | First, install the general dependencies: | ||||
sudo apt update | sudo apt update | ||||
sudo apt upgrade | sudo apt upgrade | ||||
sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git | sudo apt install autoconf automake build-essential bsdmainutils curl git libboost-all-dev libevent-dec libssl-dev libtool ninja-build pkg-config python3 | ||||
The cmake version packaged with Ubuntu Bionic is too old for building Building Bitcoin ABC. | |||||
To install the latest version: | |||||
sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget | |||||
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - | |||||
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' | |||||
sudo apt update | |||||
sudo apt install cmake | |||||
A host toolchain (`build-essential`) is necessary because some dependency | A host toolchain (`build-essential`) is necessary because some dependency | ||||
packages (such as `protobuf`) need to build host utilities that are used in the | packages (such as `protobuf`) need to build host utilities that are used in the | ||||
build process. | build process. | ||||
See also: [dependencies.md](dependencies.md). | See also: [dependencies.md](dependencies.md). | ||||
## Building for 64-bit Windows | ## Building for 64-bit Windows | ||||
The first step is to install the mingw-w64 cross-compilation tool chain. Due to different Ubuntu | The first step is to install the mingw-w64 cross-compilation tool chain. Due to different Ubuntu | ||||
packages for each distribution and problems with the Xenial packages the steps for each are different. | packages for each distribution and problems with the Xenial packages the steps for each are different. | ||||
Common steps to install mingw32 cross compiler tool chain: | Common steps to install mingw32 cross compiler tool chain: | ||||
sudo apt install g++-mingw-w64-x86-64 | sudo apt install g++-mingw-w64-x86-64 | ||||
Ubuntu Trusty 14.04: | |||||
No further steps required | |||||
Ubuntu Xenial 16.04 and Windows Subsystem for Linux <sup>[1](#footnote1),[2](#footnote2)</sup>: | Ubuntu Xenial 16.04 and Windows Subsystem for Linux <sup>[1](#footnote1),[2](#footnote2)</sup>: | ||||
sudo apt install software-properties-common | sudo apt install software-properties-common | ||||
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu artful universe" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu artful universe" | ||||
sudo apt update | sudo apt update | ||||
sudo apt upgrade | sudo apt upgrade | ||||
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++ # Set the default mingw32 g++ compiler option to posix. | ||||
sudo update-alternatives --config x86_64-w64-mingw32-gcc # Set the default mingw32 gcc compiler option to posix. | |||||
Ubuntu Artful 17.10 <sup>[2](#footnote2)</sup>: | Ubuntu Artful 17.10 <sup>[2](#footnote2)</sup> and later, including Ubuntu Bionic on WSL: | ||||
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++ # Set the default mingw32 g++ compiler option to posix. | ||||
sudo update-alternatives --config x86_64-w64-mingw32-gcc # Set the default mingw32 gcc compiler option to posix. | |||||
Once the toolchain is installed the build steps are common: | Once the toolchain is installed the build steps are common: | ||||
Note that for WSL the Bitcoin ABC source path MUST be somewhere in the default mount file system, for | Note that for WSL the Bitcoin ABC source path MUST be somewhere in the default mount file system, for | ||||
example /usr/src/bitcoin-abc, AND not under /mnt/d/. If this is not the case the dependency autoconf scripts will fail. | example /usr/src/bitcoin-abc, AND not under /mnt/d/. | ||||
This means you cannot use a directory that is located directly on the host Windows file system to perform the build. | This means you cannot use a directory that is located directly on the host Windows file system to perform the build. | ||||
Acquire the source in the usual way: | Acquire the source in the usual way: | ||||
git clone https://github.com/Bitcoin-ABC/bitcoin-abc.git | git clone https://github.com/Bitcoin-ABC/bitcoin-abc.git | ||||
Once the source code is ready the build steps are below: | Once the source code is ready the build steps are below: | ||||
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var | PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var | ||||
cd depends | cd depends | ||||
make HOST=x86_64-w64-mingw32 | make build-win64 | ||||
cd .. | cd .. | ||||
./autogen.sh # not required when building from tarball | mkdir build | ||||
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/ --with-seeder=false # seeder not supported in Windows yet | cd build | ||||
make | cmake -GNinja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Win64.cmake -DBUILD_BITCOIN_SEEDER=OFF # seeder not supported in Windows yet | ||||
ninja | |||||
## Building for 32-bit Windows | ## Building for 32-bit Windows | ||||
To build executables for Windows 32-bit, install the following dependencies: | To build executables for Windows 32-bit, install the following dependencies: | ||||
sudo apt install g++-mingw-w64-i686 mingw-w64-i686-dev | sudo apt install g++-mingw-w64-i686 mingw-w64-i686-dev | ||||
For Ubuntu Xenial 16.04, Ubuntu Artful 17.10 and Windows Subsystem for Linux <sup>[2](#footnote2)</sup>: | For Ubuntu Xenial 16.04 and later, including Ubuntu Bionic on the Windows Subsystem for Linux <sup>[2](#footnote2)</sup>: | ||||
sudo update-alternatives --config i686-w64-mingw32-g++ # 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. | ||||
sudo update-alternatives --config i686-w64-mingw32-gcc # Set the default mingw32 gcc compiler option to posix. | |||||
Note that for WSL the Bitcoin ABC source path MUST be somewhere in the default mount file system, for | Note that for WSL the Bitcoin ABC source path MUST be somewhere in the default mount file system, for | ||||
example /usr/src/bitcoin-abc, AND not under /mnt/d/. If this is not the case the dependency autoconf scripts will fail. | example /usr/src/bitcoin-abc, AND not under /mnt/d/. | ||||
This means you cannot use a directory that located directly on the host Windows file system to perform the build. | This means you cannot use a directory that located directly on the host Windows file system to perform the build. | ||||
Acquire the source in the usual way: | Acquire the source in the usual way: | ||||
git clone https://github.com/Bitcoin-ABC/bitcoin-abc.git | git clone https://github.com/Bitcoin-ABC/bitcoin-abc.git | ||||
Then build using: | Then build using: | ||||
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var | PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var | ||||
cd depends | cd depends | ||||
make HOST=i686-w64-mingw32 | make build-win32 | ||||
cd .. | cd .. | ||||
./autogen.sh # not required when building from tarball | mkdir build | ||||
CONFIG_SITE=$PWD/depends/i686-w64-mingw32/share/config.site ./configure --prefix=/ --with-seeder=false # seeder not supported in Windows yet | cd build | ||||
make | cmake -GNinja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Win32.cmake -DBUILD_BITCOIN_SEEDER=OFF # seeder not supported in Windows yet | ||||
ninja | |||||
## Depends system | ## Depends system | ||||
For further documentation on the depends system see [README.md](../depends/README.md) in the depends directory. | For further documentation on the depends system see [README.md](../depends/README.md) in the depends directory. | ||||
Installation | Installation | ||||
------------- | ------------- | ||||
After building using the Windows subsystem it can be useful to copy the compiled | After building using the Windows subsystem it can be useful to copy the compiled | ||||
executables to a directory on the windows drive in the same directory structure | executables to a directory on the windows drive in the same directory structure | ||||
as they appear in the release `.zip` archive. This can be done in the following | as they appear in the release `.zip` archive. This can be done in the following | ||||
way. This will install to `c:\workspace\bitcoin-abc`, for example: | way. This will install to `c:\workspace\bitcoin-abc`, for example: | ||||
make install DESTDIR=/mnt/c/workspace/bitcoin-abc | cmake -GNinja .. -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Win32.cmake -DBUILD_BITCOIN_SEEDER=OFF -DCMAKE_INSTALL_PREFIX=/mnt/c/workspace/bitcoin-abc | ||||
ninja install | |||||
Footnotes | Footnotes | ||||
--------- | --------- | ||||
<a name="footnote1">1</a>: There is currently a bug in the 64 bit Mingw-w64 cross compiler packaged for WSL/Ubuntu Xenial 16.04 that | <a name="footnote1">1</a>: There is currently a bug in the 64 bit Mingw-w64 cross compiler packaged for WSL/Ubuntu Xenial 16.04 that | ||||
causes two of the bitcoin executables to crash shortly after start up. The bug is related to the | causes two of the bitcoin executables to crash shortly after start up. The bug is related to the | ||||
-fstack-protector-all g++ compiler flag which is used to mitigate buffer overflows. | -fstack-protector-all g++ compiler flag which is used to mitigate buffer overflows. | ||||
Installing the Mingw-w64 packages from the Ubuntu 17.10 distribution solves the issue, however, this is not | Installing the Mingw-w64 packages from the Ubuntu 17.10 distribution solves the issue, however, this is not | ||||
Show All 9 Lines |