@@ -3,73 +3,97 @@ WINDOWS BUILD NOTES
33
44Below are some notes on how to build Bitcoin Core for Windows.
55
6- Most developers use cross-compilation from Ubuntu to build executables for
7- Windows. This is also used to build the release binaries.
6+ The options known to work for building Bitcoin Core on Windows are:
87
9- Currently only building on Ubuntu Trusty 14.04 is supported.
10- Other versions are unsupported or known to be broken (e.g. Ubuntu Xenial 16.04).
8+ * On Linux, using the [ Mingw-w64] ( https://mingw-w64.org/doku.php ) cross compiler tool chain. Ubuntu Bionic 18.04 is required
9+ and is the platform used to build the Bitcoin Core Windows release binaries.
10+ * On Windows, using [ Windows
11+ Subsystem for Linux (WSL)] ( https://msdn.microsoft.com/commandline/wsl/about ) and the Mingw-w64 cross compiler tool chain.
1112
12- While there are potentially a number of ways to build on Windows (for example using msys / mingw-w64),
13- using the Windows Subsystem For Linux is the most straightforward. If you are building with
14- another method, please contribute the instructions here for others who are running versions
15- of Windows that are not compatible with the Windows Subsystem for Linux.
13+ Other options which may work, but which have not been extensively tested are (please contribute instructions):
1614
17- Compiling with Windows Subsystem For Linux
18- -------------------------------------------
15+ * On Windows, using a POSIX compatibility layer application such as [ cygwin] ( http://www.cygwin.com/ ) or [ msys2] ( http://www.msys2.org/ ) .
16+ * On Windows, using a native compiler tool chain such as [ Visual Studio] ( https://www.visualstudio.com ) .
17+
18+ Installing Windows Subsystem for Linux
19+ ---------------------------------------
1920
2021With Windows 10, Microsoft has released a new feature named the [ Windows
21- Subsystem for Linux] ( https://msdn.microsoft.com/commandline/wsl/about ) . This
22+ Subsystem for Linux (WSL) ] ( https://msdn.microsoft.com/commandline/wsl/about ) . This
2223feature allows you to run a bash shell directly on Windows in an Ubuntu-based
2324environment. Within this environment you can cross compile for Windows without
24- the need for a separate Linux VM or server.
25+ the need for a separate Linux VM or server. Note that while WSL can be installed with
26+ other Linux variants, such as OpenSUSE, the following instructions have only been
27+ tested with Ubuntu.
2528
2629This feature is not supported in versions of Windows prior to Windows 10 or on
2730Windows Server SKUs. In addition, it is available [ only for 64-bit versions of
2831Windows] ( https://msdn.microsoft.com/en-us/commandline/wsl/install_guide ) .
2932
30- To get the bash shell, you must first activate the feature in Windows.
31-
32- 1 . Turn on Developer Mode
33- * Open Settings -> Update and Security -> For developers
34- * Select the Developer Mode radio button
35- * Restart if necessary
36- 2 . Enable the Windows Subsystem for Linux feature
37- * From Start, search for "Turn Windows features on or off" (type 'turn')
38- * Select Windows Subsystem for Linux (beta)
39- * Click OK
40- * Restart if necessary
33+ Full instructions to install WSL are available on the above link.
34+ To install WSL on Windows 10 with Fall Creators Update installed (version >= 16215.0) do the following:
35+
36+ 1 . Enable the Windows Subsystem for Linux feature
37+ * Open the Windows Features dialog (` OptionalFeatures.exe ` )
38+ * Enable 'Windows Subsystem for Linux'
39+ * Click 'OK' and restart if necessary
40+ 2 . Install Ubuntu
41+ * Open Microsoft Store and search for "Ubuntu 18.04" or use [ this link] ( https://www.microsoft.com/store/productId/9N9TNGVNDL3Q )
42+ * Click Install
41433 . Complete Installation
42- * Open a cmd prompt and type "bash"
43- * Accept the license
44+ * Open a cmd prompt and type "Ubuntu1804"
4445 * Create a new UNIX user account (this is a separate account from your Windows account)
4546
4647After the bash shell is active, you can follow the instructions below, starting
4748with the "Cross-compilation" section. Compiling the 64-bit version is
48- recommended but it is possible to compile the 32-bit version.
49+ recommended, but it is possible to compile the 32-bit version.
4950
50- Cross-compilation
51- -------------------
51+ Cross-compilation for Ubuntu and Windows Subsystem for Linux
52+ ------------------------------------------------------------
5253
53- These steps can be performed on, for example, an Ubuntu VM. The depends system
54+ The steps below can be performed on Ubuntu (including in a VM) or WSL . The depends system
5455will also work on other Linux distributions, however the commands for
5556installing the toolchain will be different.
5657
5758First, install the general dependencies:
5859
59- sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl
60+ sudo apt update
61+ sudo apt upgrade
62+ sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git
6063
6164A host toolchain (` build-essential ` ) is necessary because some dependency
6265packages (such as ` protobuf ` ) need to build host utilities that are used in the
6366build process.
6467
68+ See [ dependencies.md] ( dependencies.md ) for a complete overview.
69+
70+ If you want to build the windows installer with ` make deploy ` you need [ NSIS] ( https://nsis.sourceforge.io/Main_Page ) :
71+
72+ sudo apt install nsis
73+
6574## Building for 64-bit Windows
6675
67- To build executables for Windows 64-bit, install the following dependencies :
76+ The first step is to install the mingw-w64 cross-compilation tool chain :
6877
69- sudo apt-get install g++-mingw-w64-x86-64 mingw-w64-x86-64-dev
78+ sudo apt install g++-mingw-w64-x86-64
7079
71- Then build using:
80+ Ubuntu Bionic 18.04 <sup >[ 1] ( #footnote1 ) </sup >:
81+
82+ sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
83+
84+ Once the toolchain is installed the build steps are common:
85+
86+ Note that for WSL the Bitcoin Core source path MUST be somewhere in the default mount file system, for
87+ example /usr/src/bitcoin, AND not under /mnt/d/. If this is not the case the dependency autoconf scripts will fail.
88+ This means you cannot use a directory that is located directly on the host Windows file system to perform the build.
89+
90+ Acquire the source in the usual way:
91+
92+ git clone https://github.com/bitcoin/bitcoin.git
7293
94+ Once the source code is ready the build steps are below:
95+
96+ PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
7397 cd depends
7498 make HOST=x86_64-w64-mingw32
7599 cd ..
@@ -81,10 +105,23 @@ Then build using:
81105
82106To build executables for Windows 32-bit, install the following dependencies:
83107
84- sudo apt-get install g++-mingw-w64-i686 mingw-w64-i686-dev
108+ sudo apt install g++-mingw-w64-i686 mingw-w64-i686-dev
109+
110+ For Ubuntu Bionic 18.04 and Windows Subsystem for Linux <sup >[ 1] ( #footnote1 ) </sup >:
111+
112+ sudo update-alternatives --config i686-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.
113+
114+ Note that for WSL the Bitcoin Core source path MUST be somewhere in the default mount file system, for
115+ example /usr/src/bitcoin, AND not under /mnt/d/. If this is not the case the dependency autoconf scripts will fail.
116+ This means you cannot use a directory that located directly on the host Windows file system to perform the build.
117+
118+ Acquire the source in the usual way:
119+
120+ git clone https://github.com/bitcoin/bitcoin.git
85121
86122Then build using:
87123
124+ PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
88125 cd depends
89126 make HOST=i686-w64-mingw32
90127 cd ..
@@ -100,8 +137,22 @@ Installation
100137-------------
101138
102139After building using the Windows subsystem it can be useful to copy the compiled
103- executables to a directory on the windows drive in the same directory structure
140+ executables to a directory on the Windows drive in the same directory structure
104141as they appear in the release ` .zip ` archive. This can be done in the following
105142way. This will install to ` c:\workspace\bitcoin ` , for example:
106143
107144 make install DESTDIR=/mnt/c/workspace/bitcoin
145+
146+ You can also create an installer using:
147+
148+ make deploy
149+
150+ Footnotes
151+ ---------
152+
153+ <a name =" footnote1 " >1</a >: Starting from Ubuntu Xenial 16.04, both the 32 and 64 bit Mingw-w64 packages install two different
154+ compiler options to allow a choice between either posix or win32 threads. The default option is win32 threads which is the more
155+ efficient since it will result in binary code that links directly with the Windows kernel32.lib. Unfortunately, the headers
156+ required to support win32 threads conflict with some of the classes in the C++11 standard library, in particular std::mutex.
157+ It's not possible to build the Bitcoin Core code using the win32 version of the Mingw-w64 cross compilers (at least not without
158+ modifying headers in the Bitcoin Core source code).
0 commit comments