Building MultiChain for Windows requires working with two separate development environments:
- Visual Studio 2017 on Native Windows (for building Google's V8 JavaScript engine and a V8 service DLL for MultiChain)
- GCC MinGW cross compiler on Linux (for building the MultiChain project)
In different stages of the build, artifacts from one environment need to be available to the other environment. If possible, sharing a single physical file system is most helpful. Otherwise, files need to be copied between the two file systems (e.g. scp on Linux, pscp from Putty or WinSCP on Windows).
The ideal system combination is WSL (Windows Subsystem for Linux) on Windows 10 (Creator edition or later). Search for "Ubuntu" in the Microsoft Store.
The reminder of these instructions assumes that the the environment variable MULTICHAIN_HOME
is the root folder of MultiChain. Variables on Windows are referenced by %VAR%
, and on Linux by $VAR
or ${VAR}
.
- Visual Studio 2017 (community edition acceptable)
- Python 2.7
- Git
- CMake
- Boost 1.65.1
sudo apt update
sudo apt install -y libtool autotools-dev automake pkg-config git python python-pip nasm
sudo apt install -y g++-mingw-w64-x86-64 mingw-w64-x86-64-dev
sudo pip install pathlib2
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:
Note: If sources on the Windows system are accessible from Linux, you can ignore the stage "Prepare a build area on the Linux machine".
On Linux:
-
In the location where you want to build MultiChain:
git clone https://github.com/MultiChain/multichain.git cd multichain export MULTICHAIN_HOME=$(pwd)
On Windows:
-
In the location where you want to build MultiChain:
git clone https://github.com/MultiChain/multichain.git cd multichain set MULTICHAIN_HOME=%CD%
On Windows:
cd %MULTICHAIN_HOME%
mkdir v8build
cd v8build
You can use pre-built headers and binaries of Google's V8 JavaScript engine by downloading and expanding windows-v8.zip in the current directory (and skip the rest of this section).
If, on the other hand, you prefer to build the V8 component yourself, please perform the following:
-
Follow the instructions in V8_win.md to fetch, configure and build Google's V8 JavaScript engine.
-
To facilitate building an additional library required by MultiChain, copy the following files to the Linux machine, in the same relative folder:
%MULTICHAIN_HOME%\v8build\v8\out.gn\x64.release\*.bin -> $MULTICHAIN_HOME/v8build/v8/out.gn/x64.release %MULTICHAIN_HOME%\v8build\v8\out.gn\x64.release\*.dat -> $MULTICHAIN_HOME/v8build/v8/out.gn/x64.release
On Linux:
export RELEASE_HOME=$MULTICHAIN_HOME/v8build/v8/out.gn/x64.release
cd $RELEASE
mkdir obj
python $MULTICHAIN_HOME/depends/v8_data_lib.py -m $MULTICHAIN_HOME -o win32
- Copy
obj/v8_data.lib
to%MULTICHAIN_HOME%\v8build\v8\out.gn\x64.release\obj
on Windows.
On Windows:
cd %MULTICHAIN_HOME%\src\v8_win
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" ..
-
If CMake cannot find your Boost installation, try the following command, replacing the location of Boost if it is installed somewhere else:
cmake -DBOOST_ROOT=C:\local\boost_1_65_1 -G "Visual Studio 15 2017 Win64" ..
-
Build the MultiChain V8 service DLL
cmake --build . --config Release --target spdlog cmake --build . --config Release
-
Copy
%MULTICHAIN_HOME%\src\v8_win\build\Release\multichain_v8.lib
to$MULTICHAIN_HOME/src/v8_win/build/Release
on Linux. -
Copy
%MULTICHAIN_HOME%\src\v8_win\build\Release\multichain_v8.dll
to%MULTICHAIN_HOME%\src
(on local Windows).
On Linux:
cd $MULTICHAIN_HOME
./autogen.sh
cd depends
make HOST=x86_64-w64-mingw32
cd ..
./configure --prefix=$(pwd)/depends/x86_64-w64-mingw32 --enable-cxx --disable-shared --enable-static --with-pic
make
- This will build
multichaind.exe
,multichain-cli.exe
andmultitchain-util.exe
in thesrc
directory1. - Copy
src/multichaind.exe
,src/multichain-cli.exe
andsrc/multitchain-util.exe
to%MULTICHAIN_HOME%\src
on Windows.
On Windows:
cd %MULTICHAIN_HOME%
src\multichaind.exe --help
- If all went well, you should see the expected help text from the program.
Notes:
1. If you have more than one CPU on your machine, you can speed things up using the -j#
flag on the last make
command.