primecoin-compile 0.8.6 version

ubuntu 14.04 版本下编译,
ubuntu 16.04 compile linux version success
windows version use windows7 compile success

修改版本
primecoin-qt.pro
share/setup.nsi
share/genbuild.sh
src/clientversion.h (change CLIENT_VERSION_IS_RELEASE to true)
下面的文件是生成的地方。undefine 两个判断宏
src/version.cpp

test

Unit tests for the core code are in `src/test/`. To compile and run them:

cd src; make -f makefile.unix test

Unit tests for the GUI code are in `src/qt/test/`. To compile and run them:

qmake BITCOIN_QT_TEST=1 -o Makefile.test primecoin-qt.pro
make -f Makefile.test
./primecoin-qt_test

linux

在 ubuntu 16.04 下面编译通过, primecoind, primecoin-qt

sudo apt install pkg-config libpng12-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev

apt-get install qt4-qmake libqt4-dev build-essential libboost-dev libboost-system-dev \
libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev \
libssl-dev libdb++-dev libminiupnpc-dev

compile db-4.8.30.NC

tar -xvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
mkdir -p build
BDB_PREFIX=$(pwd)/build
../dist/configure --disable-shared --enable-cxx --with-pic --prefix=$BDB_PREFIX
make
make install
cd ../..

compile primecoind

cd src/
BDB_INCLUDE_PATH=${BDB_PREFIX}/include BDB_LIB_PATH=${BDB_PREFIX}/lib make -f makefile.unix STATIC=1
# 清除编译产生的可执行文件及目标文件(object file,*.o)
make -f makefile.unix clean

compile primecoin-qt

qmake
make

window7 compile

参考文章

Prepare your build system

  • Install msys shell
    download
    From MinGW installation manager -> All packages -> MSYS
    mark the following for installation:

msys-base-bin
msys-autoconf-bin
msys-automake-bin
msys-libtool-bin

Make sure no mingw packages are checked for installation or present from a previous install.
Only the above msys packages should be installed.
Also make sure that msys-gcc and msys-w32api packages are not installed.

then click on Installation -> Apply changes

  • Install MinGW-builds project toolchain:

32bit
Download

64bit
download

and unpack it to C:\

下面使用 32bit 操作,如果需要64bit 对应换一下mingw64
Ensure that mingw-builds bin folder is set in your PATH environment variable. On Windows 7 your path should look something like:
C:\mingw32\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

Your gcc -v output should be:

$ gcc -v
Using built-in specs.
COLLECT_GCC=c:\mingw32\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw32/bin/../libexec/gcc/i686-w64-mingw32/4.9.2/lto-wrapper.exe
Target: i686-w64-mingw32
...
Thread model: posix
gcc version 4.9.2 (i686-posix-dwarf-rev1, Built by MinGW-W64 project)

Download, unpack and build required dependencies.
I’ll save them in c:\deps folder.

depends

Warning: you need clean before build 64/32 separately

OpenSSL

Note that openssl v1.0.1g and later may lead to consesus forks:
http://sourceforge.net/p/primecoin/mailman/message/33221963/

download
From a MinGw shell (C:\MinGW\msys\1.0\msys.bat), unpack the source archive with tar (this will avoid symlink issues) then configure and make:

32bit

cd /c/deps/
tar xvfz openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
./Configure no-zlib no-shared no-dso no-krb5 no-camellia no-capieng no-cast no-cms no-dtls1 no-gost no-gmp no-heartbeats no-idea no-jpake no-md2 no-mdc2 no-rc5 no-rdrand no-rfc3779 no-rsax no-sctp no-seed no-sha0 no-static_engine no-whirlpool no-rc2 no-rc4 no-ssl2 no-ssl3 mingw
make

64bit

cd /c/deps/
tar xvfz openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
./Configure no-zlib no-shared no-dso no-krb5 no-camellia no-capieng no-cast no-cms no-dtls1 no-gost no-gmp no-heartbeats no-idea no-jpake no-md2 no-mdc2 no-rc5 no-rdrand no-rfc3779 no-rsax no-sctp no-seed no-sha0 no-static_engine no-whirlpool no-rc2 no-rc4 no-ssl2 no-ssl3 mingw64
make

Berkeley DB

download
From a MinGW shell unpack the source archive, configure and make:

cd /c/deps/
tar xvfz db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
../dist/configure --enable-mingw --enable-cxx --disable-shared --disable-replication
make

Boost

download
Download either the zip or the 7z archive, unpack boost inside your C:\deps folder, then bootstrap and compile
This will compile the required boost libraries and put them into the stage folder (C:\deps\boost_1_57_0\stage).
Note: make sure you don’t use tarballs, as unix EOL markers can break batch files.

From a Windows command prompt:

cd C:\deps\boost_1_57_0\
bootstrap.bat mingw
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc variant=release link=static threading=multi runtime-link=static stage

after build you can delete bin.v2 folder

修改 boost/type_traits/detail/has_binary_operator.hpp

add to the top:
#ifndef Q_MOC_RUN

add to the bottom:
#endif

Miniupnpc

ref.
新版的 upnpc 需要添加新宏

CPPFLAGS="$CPPFLAGS -DSTATICLIB"
改为
MINIUPNPC_CPPFLAGS="-DSTATICLIB -DMINIUPNP_STATICLIB"

libprimecoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES)
改为
libprimecoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS)

download
Unpack Miniupnpc to C:\deps, rename containing folder from “miniupnpc-1.9.20150206” to “miniupnpc” then from a Windows command prompt:

cd C:\deps\miniupnpc
mingw32-make -f Makefile.mingw init upnpc-static

qrencode

libpng
Download and unpack inside your deps folder then configure and make within MinGW shell:

cd /c/deps/libpng-1.6.16
configure --disable-shared
make
cp .libs/libpng16.a .libs/libpng.a

qrencode
Download and unpack inside your deps folder then configure and make within MinGW shell:

32bit

cd /c/deps/qrencode-3.4.4

LIBS="../libpng-1.6.16/.libs/libpng.a ../../mingw32/i686-w64-mingw32/lib/libz.a" \
png_CFLAGS="-I../libpng-1.6.16" \
png_LIBS="-L../libpng-1.6.16/.libs" \
configure --enable-static --disable-shared --without-tools

make

64bit

cd /c/deps/qrencode-3.4.4

LIBS="../libpng-1.6.16/.libs/libpng.a ../../mingw64/i686-w64-mingw32/lib/libz.a" \
png_CFLAGS="-I../libpng-1.6.16" \
png_LIBS="-L../libpng-1.6.16/.libs" \
configure --enable-static --disable-shared --without-tools

make

如果没有编译primecoind 或者 执行了 clean 操作需要重新编译 LevelDB,特别是编译完32bit,在编译64bit 的时候
make within MinGW shell

TARGET_OS=NATIVE_WINDOWS make clean
cd /C/primecoin-0.8.6/src/leveldb
TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a

primecoin

With a texteditor edit BOOST_SUFFIX, INCLUDEPATHS and LIBPATHS in your C:\primecoin-0.8.6\src\makefile.mingw according to your dependencies location:

BOOST_SUFFIX?=-mgw49-mt-s-1_57

INCLUDEPATHS= \
-I"$(CURDIR)" \
-I"/c/deps/boost_1_57_0" \
-I"/c/deps/db-4.8.30.NC/build_unix" \
-I"/c/deps/openssl-1.0.1g/include"

LIBPATHS= \
-L"$(CURDIR)/leveldb" \
-L"/c/deps/boost_1_57_0/stage/lib" \
-L"/c/deps/db-4.8.30.NC/build_unix" \
-L"/c/deps/openssl-1.0.1g"

and add -static option to LDFLAGS in makefile.mingw to compile a statically linked executable.
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -Wl,--large-address-aware -static
Upnp support is disabled by default. If you want to compile with upnp support set
USE_UPNP:=1

and add miniupnpc path to INCLUDEPATHS and LIBPATHS:

INCLUDEPATHS= \
-I"$(CURDIR)" \
-I"/c/deps/boost_1_57_0" \
-I"/c/deps" \
-I"/c/deps/db-4.8.30.NC/build_unix" \
-I"/c/deps/openssl-1.0.1g/include"

LIBPATHS= \
-L"$(CURDIR)/leveldb" \
-L"/c/deps/boost_1_57_0/stage/lib" \
-L"/c/deps/miniupnpc" \
-L"/c/deps/db-4.8.30.NC/build_unix" \
-L"/c/deps/openssl-1.0.1g"

compile 64bit
modify util.h

// for mingw64 compile
#if !defined(__MINGW32__) || !defined(_PID_T_) || defined(_NO_OLDNAMES)
typedef int pid_t; /* define for Windows compatibility */
#endif

unrecognized option '--large-address-aware'
solution: remove -Wl,--large-address-aware, this is only for x86 target

modify compat.h

#if !defined(__MINGW32__)
typedef u_int SOCKET;
#endif

修改 primecoin/src/makefile.mingw
在最上面添加

ARCH ?= $(shell getconf LONG_BIT)
CPP_FLAGS_32 := --large-address-aware
CPP_FLAGS_64 :=

CXX ?= g++

From Msys shell compile primecoind:

cd /c/primecoin-0.8.6/src
make -f makefile.mingw ARCH=64
strip primecoind.exe

Qt4

Compile primecoin-qt 0.8.6 with Qt 4.8:
Download
Assuming qt sources have been unpacked to C:\Qt\4.8.6, from a windows command prompt:

cd C:\Qt\4.8.6
configure -release -opensource -confirm-license -static -no-sql-sqlite -no-qt3support -no-opengl -qt-zlib -no-gif -qt-libpng -qt-libmng -no-libtiff -qt-libjpeg -no-dsp -no-vcproj -no-openssl -no-dbus -no-phonon -no-phonon-backend -no-multimedia -no-audio-backend -no-webkit -no-script -no-scripttools -no-declarative -no-declarative-debug -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde -nomake demos -nomake examples -static

mingw32-make

Note that if you skipped primecoind compilation or if you have cleaned up your source folder you will need to compile libleveldb.a and libmemenv.a libraries before proceeding.
From msys shell:

cd /C/primecoin-0.8.6/src/leveldb
TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a

Edit C:\primecoin-0.8.6\primecoin-qt.pro with your favourite text editor and add
dependency library locations:

# Dependency library locations can be customized with:
# BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
# BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively

BOOST_LIB_SUFFIX=-mgw49-mt-s-1_57
BOOST_INCLUDE_PATH=C:/deps/boost_1_57_0
BOOST_LIB_PATH=C:/deps/boost_1_57_0/stage/lib
BDB_INCLUDE_PATH=C:/deps/db-4.8.30.NC/build_unix
BDB_LIB_PATH=C:/deps/db-4.8.30.NC/build_unix
OPENSSL_INCLUDE_PATH=C:/deps/openssl-1.0.1g/include
OPENSSL_LIB_PATH=C:/deps/openssl-1.0.1g
MINIUPNPC_INCLUDE_PATH=C:/deps/
MINIUPNPC_LIB_PATH=C:/deps/miniupnpc
QRENCODE_INCLUDE_PATH=C:/deps/qrencode-3.4.4
QRENCODE_LIB_PATH=C:/deps/qrencode-3.4.4/.libs

Comment out genleveldb.commands for windows

LIBS += -lshlwapi
#genleveldb.commands = cd $$PWD/src/leveldb && CC=$$QMAKE_CC CXX=$$QMAKE_CXX TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) OPT=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\" libleveldb.a libmemenv.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libleveldb.a && $$QMAKE_RANLIB $$PWD/src/leveldb/libmemenv.a
}

flags for static build:

CONFIG += static
win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static

去掉 -Wl,–large-address-aware 这个是Windows 32bit 用的

From a windows command prompt configure and make:

set PATH=%PATH%;C:\deps\qt-everywhere-opensource-src-4.8.6\bin
cd C:\primecoin-0.8.6\
qmake "USE_QRCODE=1" "USE_UPNP=-" "USE_IPV6=1" bitcoin-qt.pro
mingw32-make -f Makefile.Release

打包

安装 nsis 然后添加到 path 路径中。
手动修改 share/setup.nsi 使用绝对路径

// package installer
makensis share/setup.nsi

cross compile to windows

not working yet. lots problem raise

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

You need the Qt4 run-time libraries to run Primecoin-Qt. On Debian or Ubuntu:
sudo apt install libqtgui4
  • 安装 mingw-w64
    sudo apt-get install mingw-w64
    安装完成后,mingw-gcc和mingw-g++默认使用的线程模型是win32的,但是我们需要使用posix的线程模型,因此分别执行以下命令,然后将工具链指向带-posix后缀的工具链

    sudo update-alternatives --config x86_64-w64-mingw32-gcc
    sudo update-alternatives --config x86_64-w64-mingw32-g++
    sudo update-alternatives --config x86_64-w64-mingw32-gfortran
    sudo update-alternatives --config x86_64-w64-mingw32-gnat

    sudo update-alternatives --config i686-w64-mingw32-gcc
    sudo update-alternatives --config i686-w64-mingw32-g++
    sudo update-alternatives --config i686-w64-mingw32-gfortran
    sudo update-alternatives --config i686-w64-mingw32-gnat
    执行上面这一步后会让你选择,我们选择x86_64-w64-mingw32-g++-posix.

编译工具链所在的目录以及gcc文件前缀为:
/usr/bin/x86_64-w64-mingw32-

x86_64-w64-mingw32 64bit compile
i686-w64-mingw32 32bit compile

通常的步骤
./configure –host=x86_64-w64-mingw32
make

zlib

cd $HOME/mingw/zlib-1.2.8.dfsg
mingw ./configure
mingw make libz.a
DESTDIR=$HOME/mingw mingw make install

cross compile openssl

openssl-1.0.1g.tar.gz

mingw for 32bit i686-w64-mingw32 and mingw64 for 64bit x86_64-w64-mingw32

for 32bit
./Configure mingw shared --cross-compile-prefix=i686-w64-mingw32-
for 64bit

./Configure mingw64 no-shared no-zlib --cross-compile-prefix=x86_64-w64-mingw32- --prefix=/usr/local/ --openssldir=/usr/local/ssl-x86_64-w64-mingw32
make
sudo make install_sw

cross compile berkeley db

db-4.8.30.NC.tar.gz

tar -xvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix
mkdir -p build
BDB_PREFIX=$(pwd)/build

env CC=/usr/bin/x86_64-w64-mingw32-gcc STRIP=/usr/bin/x86_64-w64-mingw32-strip ../dist/configure --host=x86_64-w64-mingw32 --enable-mingw --disable-shared --enable-cxx --with-pic --prefix=$BDB_PREFIX --disable-pthread_api --disable-replication

make install
cd ../..

cross compile boost

./bootstrap.sh --without-icu
echo "using gcc : 5.4 : x86_64-w64-mingw32-gcc
:
<rc>x86_64-w64-mingw32-windres
<archiver>x86_64-linux-gnu-gcc-ar
;" > user-config.jam
# build boost and install them into the directory $PREFIX
sudo ./bjam stage toolset=gcc target-os=windows variant=release threading=multi threadapi=win32\
link=static runtime-link=static --prefix=$PREFIX --user-config=user-config.jam -j 2\
--without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged install

cross compile primecoin

Btw, if using “USE_UPNP=-“ option, then no issues.

gcc g++
mingw-get install mingw32-make

sudo gedit /etc/apt/sources.list
//在sources.list末尾添加,保存
deb http://us.archive.ubuntu.com/ubuntu trusty main universe
sudo apt-get update
sudo apt-get install mingw32


cd /primecoin/src
make -f makefile.linux-mingw
strip primecoind.exe