-
Notifications
You must be signed in to change notification settings - Fork 3
Setting up crossbuild environment from scratch
1) Create fresh ubuntu 14.04 (Trusty Tahr) VM
http://cdimage.ubuntu.com/daily-live/current/trusty-desktop-amd64.iso
2) Install packages
$ sudo apt-get update && sudo apt-get upgrade $ sudo apt-get install build-essential libgmp-dev libgmp3-dev git cmake m4 \ libboost-all-dev automake libtool libleveldb-dev yasm unzip lzip libminiupnpc-dev \ mingw-w64 gcc-mingw-w64 g++-mingw-w64 binutils-mingw-w64
For full Qt client:
$ sudo apt-get install qtbase5-dev qt5-default
3) Build boost for windows
$ wget http://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.bz2 $ tar xjvf boost_1_55_0.tar.bz2 $ cd boost_1_55_0 $ ./bootstrap.sh --without-icu $ echo "using gcc : mingw32 : x86_64-w64-mingw32-g++ : <rc>x86_64-w64-mingw32-windres <archiver>x86_64-w64-mingw32-ar <ranlib>x86_64-w64-mingw32-ranlib ;" > user-config.jam $ sudo ./bjam toolset=gcc address-model=64 target-os=windows variant=release threading=multi threadapi=win32 \ link=static runtime-link=static --prefix=/usr/x86_64-w64-mingw32 --user-config=user-config.jam \ --without-mpi --without-python -sNO_BZIP2=1 --layout=tagged install $ cd ..
(-Wno-unused-local-typedefs to suppress warnings)
4) Build zlib for windows (required by Qt5)
$ wget http://zlib.net/zlib-1.2.8.tar.gz $ tar xzvf zlib-1.2.8.tar.gz $ cd zlib-1.2.8 $ CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar RANLIB=x86_64-w64-mingw32-ranlib ./configure --prefix=/usr/x86_64-w64-mingw32 --static $ make $ sudo make install $ cd ..
5) Build Qt5 for windows (not required for headless daemon)
$ wget http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.tar.gz $ tar xzvf qt-everywhere-opensource-src-5.2.1.tar.gz
Qt5.2.1 has some problems with preprocessor definitions when building with MinGW.
$ sed -i -e 's/QT_NO_SESSIONMANAGER/__QT_NO_SESSIONMANAGER/g' \ ~/qt-everywhere-opensource-src-5.2.1/qtbase/src/gui/kernel/qplatformsessionmanager.h \ ~/qt-everywhere-opensource-src-5.2.1/qtbase/src/gui/kernel/qsessionmanager.h
$ export INSTALLPREFIX=/usr/x86_64-w64-mingw32 $ mkdir qt5-w64-build $ cd qt5-w64-build $ ../qt-everywhere-opensource-src-5.2.1/configure -prefix / -hostprefix $INSTALLPREFIX/host -plugindir /plugins -translationdir /translations \ -xplatform win32-g++ -device-option CROSS_COMPILE=x86_64-w64-mingw32- -sysroot $INSTALLPREFIX -confirm-license -release -opensource -static -qt-pcre \ -no-icu -no-glib -no-javascript-jit -no-sql-sqlite -no-nis -no-cups -no-iconv -no-dbus -nomake examples \ -no-feature-style-plastique -no-feature-style-cleanlooks -no-feature-style-motif -no-feature-style-cde -no-feature-style-windowsce \ -no-feature-style-windowsmobile -no-feature-style-s60 -no-pch -no-sql-odbc -no-compile-examples -no-qml-debug -no-sm \ -skip qtwebkit -skip qtwebkit-examples -skip qtactiveqt -no-openssl -qt-zlib $ make $ sudo make install $ cd ..
(-Wno-strict-overflow -Wno-strict-aliasing -Wno-unused-parameters to suppress warnings)
Patch Qt5.2.1 to work with cmake for static build. Windows uses library naming convention name.lib, MinGW uses libname.a. So we must replace the names:
$ cd /usr/x86_64-w64-mingw32/lib/cmake $ sudo sed -i -e 's/\/\([^\.]*\)\.lib/\/lib\1\.a/g' $(find * -type f)
6) Build leveldb for windows
$ git clone https://github.com/bitcoin/bitcoin.git $ cp bitcoin/src/leveldb ./ -R $ cd leveldb $ TARGET_OS=NATIVE_WINDOWS CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ AR=x86_64-w64-mingw32-ar \ make libleveldb.a libmemenv.a $ sudo cp include/leveldb /usr/x86_64-w64-mingw32/include/ -R $ sudo cp *.a /usr/x86_64-w64-mingw32/lib/ $ cd ..
7) Build gmp for windows
$ wget https://gmplib.org/download/gmp/gmp-5.1.3.tar.lz $ lzip -d gmp-5.1.3.tar.lz $ tar xvf gmp-5.1.3.tar $ mkdir gmp-w64-build $ cd gmp-w64-build $ ../gmp-5.1.3/configure --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32 $ make $ sudo make install $ cd ..
8) Build miniupnpc for windows
$ wget http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.9.tar.gz -O miniupnpc-1.9.tar.gz $ tar xzvf miniupnpc-1.9.tar.gz $ cd miniupnpc-1.9 $ CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CFLAGS="-DSTATICLIB -I/usr/x86_64-w64-mingw32/include" LDFLAGS=-L/usr/x86_64-w64-mingw32/lib \ make libminiupnpc.a $ sudo mkdir /usr/x86_64-w64-mingw32/include/miniupnpc $ sudo cp *.h /usr/x86_64-w64-mingw32/include/miniupnpc/ $ sudo cp libminiupnpc.a /usr/x86_64-w64-mingw32/lib/ $ cd ..
9) Build cryptopp-5.6.2 for linux and windows
$ mkdir cryptopp562 $ cd cryptopp562 $ wget http://www.cryptopp.com/cryptopp562.zip $ unzip cryptopp562.zip
Linux $ make static $ sudo mkdir /usr/include/cryptopp $ sudo cp *.h /usr/include/cryptopp $ sudo cp libcryptopp.a /usr/lib $ make clean
Windows $ CXX=x86_64-w64-mingw32-g++ AR=x86_64-w64-mingw32-ar make static $ x86_64-w64-mingw32-ranlib libcryptopp.a $ sudo mkdir /usr/x86_64-w64-mingw32/include/cryptopp $ sudo cp *.h /usr/x86_64-w64-mingw32/include/cryptopp $ sudo cp libcryptopp.a /usr/x86_64-w64-mingw32/lib $ make clean
(-Wno-deprecated to suppress warnings)
$ cd ..
10) Qt5.2.1 + cmake opengl issue workaround. Qt5GuiConfigExtras.cmake tries to use opengl (glu32). Prevent it from looking for it.
$ sudo sed -i -e 's/_qt5gui_find_extra_libs(OPENGL/#_qt5gui_find_extra_libs(OPENGL/g' \ /usr/x86_64-w64-mingw32/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake
- Building on Linux
- Building on MacOS
- Building on Windows
- Compatibility Info and Build Tips
- Serpent LLL Only Build
- LLL PoC 6
- [LLL Examples for PoC 6](LLL Examples for PoC 5)
- PoC 6 JS API
- Client Development with PoC 6
- MetaCoin API
- Exchange API
- Name Registration API
- Coins API