Build Windows peercoin qt.exe using MXE on Linux - nohea/peercoin GitHub Wiki

Tested on Ubuntu 14.04 LTS, Ubuntu 16.04 LTS

This is for building the Peercoin graphical UI executable for Microsoft Windows operating systems, on Linux.

Install required packages

sudo apt-get install autoconf automake autopoint bash bison bzip2 flex gettext git g++ gperf intltool libffi-dev libgdk-pixbuf2.0-dev libtool libltdl-dev libssl-dev libxml-parser-perl make openssl p7zip-full patch perl pkg-config python ruby scons sed unzip wget xz-utils
sudo apt-get install g++-multilib libc6-dev-i386

May need to install libtool-bin if no libtool package.

Install MXE from Github

MXE mxe.cc is a cross-compilation environment for various platforms. Here we use it to target the Windows environment using MingW. We install the dependent libraries for the target before compiling our exe.

cd /opt
sudo mkdir mxe
sudo chown myusername:myusername mxe
git clone https://github.com/mxe/mxe.git
cd mxe

download and install library packages from source using the MXE makefiles.

make boost
make openssl
make miniupnpc
make pthreads
make qt5

Note: if you have the error "virtual memory exhausted: Cannot allocate memory" during make boost, you need more virtual memory. If you only have 1GB RAM configured, create a 2GB swapfile using dd and mkswap, and do "swapon swapfilename", try again.

Manually download separate dependencies and install under the MXE environment

Do not install the latest 'db' package via MXE. Install the db 4.8 version specifically, to maintain compatibility of the wallet.dat files.

cd /opt
sudo mkdir mxe-deps
sudo chown myusername:myusername mxe-deps
cd mxe-deps
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.zip
unzip db-4.8.30.NC.zip
cd /opt/mxe/
make db SOURCE_TREE=/opt/mxe-deps/db-4.8.30.NC

Compile libqrencode

MXE does not provide the script for libqrencode, but there is a qrencode.mk pull request pending. https://github.com/mxe/mxe/pull/1890

To use, download to your local mxe/src/ directory.

cd src
wget https://raw.githubusercontent.com/nohea/mxe/qrencode-add/src/qrencode.mk
cd ..

Run make qrencode just like the supported packages:

make qrencode

libqrencode will be built in your mxe installation, and you may pass the "USE_QRCODE=1" parameter to include QR code support in the qmake-qt5 command later.

build peercoin-qt.exe in a user directory

git clone the peercoin/peercoin source code from github

cd ~/code
git clone https://github.com/peercoin/peercoin.git
cd peercoin

0.6 branch

git checkout develop

or checkout the relevant v0.6.0ppc.rc* branch.

The Makefile's make clean created by qmake doesn't correctly clean up the src/leveldb/ subdirectory. So on repeated builds you may have to execute this manually:

cd src/leveldb/
make clean
cd ../..

QT5 qmake expects the tools in the PATH environment variable.

Do this before running:

export PATH=$PATH:/opt/mxe/usr/bin

Run qmake and make to build.

/opt/mxe/usr/bin/i686-w64-mingw32.static-qmake-qt5 "QMAKE_CC=/opt/mxe/usr/bin/i686-w64-mingw32.static-gcc" "QMAKE_CXX=/opt/mxe/usr/bin/i686-w64-mingw32.static-g++" "OPENSSL_INCLUDE_PATH=/opt/mxe/usr/i686-w64-mingw32.static/include" "OPENSSL_LIB_PATH=/opt/mxe/usr/i686-w64-mingw32.static/lib" "BDB_INCLUDE_PATH=/opt/mxe/usr/i686-w64-mingw32.static/include" "BDB_LIB_PATH=/opt/mxe/usr/i686-w64-mingw32.static/lib" "MINIUPNPC_INCLUDE_PATH=/opt/mxe/usr/i686-w64-mingw32.static/include" "MINIUPNPC_LIB_PATH=/opt/mxe/usr/i686-w64-mingw32.static/lib" "QMAKE_CXXFLAGS=-std=c++11 -DBOOST_NO_CXX11_SCOPED_ENUMS" "QMAKE_RANLIB=/opt/mxe/usr/bin/i686-w64-mingw32.static-ranlib" "QMAKE_LRELEASE=/opt/mxe/usr/i686-w64-mingw32.static/qt5/bin/lrelease" "AR=/opt/mxe/usr/bin/i686-w64-mingw32.static-ar" "RELEASE=1" BOOST_LIB_SUFFIX=-mt BOOST_THREAD_LIB_SUFFIX=_win32-mt "USE_UPNP=0" "USE_QRCODE=1" bitcoin-qt.pro

make

You will have release/peercoin-qt.exe ready to copy to a Windows machine and run.