1. 程式人生 > >Ubuntu下編譯windows版本bitcoin

Ubuntu下編譯windows版本bitcoin

要編譯windows版的比特幣程式,基本上有兩種方法,一種是在linux平臺(推薦ubuntu 13.10)通過交叉編譯的方法來編譯,另外一種就是直接在windows平臺編譯。

下面就詳細介紹一下如何在Ubuntu平臺編譯比特幣程式。

Ubuntu 環境安裝

方法1:安裝Ubuntu虛擬機器
方法2:在Windows10上安裝Windows Subsystem for Linux,安裝Ubuntu子系統

交叉編譯環境依賴安裝

sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git

構建64-bit Windows版本

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.

Common steps to install mingw32 cross compiler tool chain:

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 1,2:

sudo apt install software-properties-common
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu zesty universe"
sudo apt update
sudo apt upgrade
sudo update-alternatives --config x86_64-w64-mingw32-g++ # Set the default mingw32 g++ compiler option to posix.

Ubuntu Zesty 17.04 2:

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

checkout sourece code:

git clone https://github.com/bitcoin/bitcoin.git

build steps:

PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
cd depends
make HOST=x86_64-w64-mingw32 #參見https://github.com/bitcoin/bitcoin/blob/master/depends/README.md
cd ..
./autogen.sh # not required when building from tarball
CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
make

構建32-bit Windows版本

To build executables for Windows 32-bit, install the following dependencies:

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

For Ubuntu Xenial 16.04, Ubuntu Zesty 17.04 and Windows Subsystem for Linux 2:

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

checkout:

git clone https://github.com/bitcoin/bitcoin.git

build steps:

PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
cd depends
make HOST=i686-w64-mingw32
cd ..
./autogen.sh # not required when building from tarball
CONFIG_SITE=$PWD/depends/i686-w64-mingw32/share/config.site ./configure --prefix=/
make