【比特幣】自己動手編譯比特幣客戶端
https://github.com/imharrywu/fastcoin本帖只談技術實現,首先我們自己來編譯一個比特幣客戶端吧, 技術討論QQ群,161928517,歡迎大家入夥(註明:csdn)。
2014.7.18更新:
靜態編譯的第三方依賴和MINGW64工具鏈以及v0.9.1的官方原始碼:
本文遇到的問題大部分是使用動態庫構建的時候遇到的,僅僅作為一個備份,大家可以直接遷出上面的程式碼或者直接跳到本文的最後看《自動指令碼》
不帶任何qt-style風格的qt介面庫構建出來的比特幣satoshi客戶端
=======================================================================================================================
先看一下最後編出來的帶qt前端的客戶端版本截圖,會有測試版本提示 (使用tag的原始碼編譯正式版本)
(建議:備份您之前安裝的%APPDATA%bitcoin目錄)。
參考github上的描述檔案
1) 簽出程式碼
GitHub上的官方原始碼
git clone https://github.com/bitcoin/bitcoin.git
也可以從csdn的code上籤出本文的整個專案組
git clone git://code.csdn.net/wuzh1230/bitcoin.git
提示:
<1>已經包含了預編譯的依賴庫在3rd目錄下;
<2>已經包含了ming32工具鏈,請修改msys/1.0/etc/fstab。
<3>文章遇到的問題大多是使用動態庫構造的時候遇到的,建議大家用--enable-static構造所有的依賴,直接跳到最後一節《自動指令碼》。
2) 下載依賴包
Libraries you need to download separately and build:
name default path download ---------------------------------------------------- OpenSSL \openssl-1.0.1c-mgw http://www.openssl.org/source/ Berkeley DB \db-4.8.30.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html Boost \boost-1.50.0-mgw http://www.boost.org/users/download/ miniupnpc \miniupnpc-1.6-mgw http://miniupnp.tuxfamily.org/files/
3) 編譯依賴包
3.1) OpenSSL
cd /c/openssl-1.0.1c-mgw
./config
make
未發現問題,如有任何問題,歡迎討論。
3.2) Berkeley DB
cd /c/db-4.8.30.NC-mgw/build_unix
sh ../dist/configure --enable-mingw --enable-cxx --disable-replication
make
注意:解除安裝mingw安裝包中pthread元件,否則,BDB會嘗試構建repmgr模組(repmgr_posix.c需要posix支援,mingw32不支援)。
注意:2014.4.19更新,在用i686-w64-ming32編譯的時候發現,repmgr模組還依賴iostream標準標頭檔案,可以考慮直接--disable-replication,而不必刪除編譯器的pthread元件。sh ../dist/configure --enable-mingw --enable-cxx --disable-replication
3.3) Boost
downloaded boost jam 3.1.18
cd \boost-1.50.0-mgw
(0) 修改一個類的dll匯出修飾 boost\program_options\detail\config_file.hpp, 參考最好的注意事項
(1) 準備bjam.exe,考慮到boost對mingw的支援不是很好,折中的辦法是用vc++的命令列構建一個bjam(比如:bootstrap.bat vc9);然後用這個b2.exe構建mingw版本的boost。
(2)執行 b2 --prefix=/d/workspace/temp install toolset=gcc link=shared variant=release runtime-link=shared threading=multi --without-mpi --without-python --without-wave --without-graph --without-graph_parallel
3.4) MiniUPnPc
cd /c/miniupnpc-1.6-mgw
make -f Makefile.mingw
mkdir miniupnpc
cp *.h miniupnpc/
(1)修改一個miniupnpc.def裡面的LIBRARY指定的庫名稱為空的問題;
(2)修改一個Makefile.mingw的del命令;
(3)新增-Wl,字首給-enable-stdcall-fixup選項
(4)可以考慮使用最新的版本,1.9.20140401版本,已經修復了上面提到的3個問題
3.5) libpng
編譯png編碼庫(libpng下載地址)支援二維碼生成
./configure --prefix=/usr/local/libpng-1.6.10 && make && make install
3.6) qrencode
二維碼編碼庫( 下載QREncode地址),需要png和pkg-config支援,下載一個解壓到mingw目錄下
./configure --prefix=/usr/local/qrencode-3.4.3 png_CFLAGS="-I/usr/local/libpng-1.6.10/include" png_LIBS="-L/usr/local/libpng-1.6.10/lib -lpng16" && make && make install
3.7) zlib
$ make -f win32/Makefile.gcc install \
SHARED_MODE=1 \
DESTDIR=/usr/local/zlib-1.2.8/ \
BINARY_PATH=bin \
INCLUDE_PATH=include \
LIBRARY_PATH=lib
3.8) protobuf
$ ./configure --prefix=/usr/local/protobuf-2.5.0 \
CPPFLAGS=-I/usr/local/zlib-1.2.8/include\
LDFLAGS=-L/usr/local/zlib-1.2.8/lib \
LIBS=-lz
4) 編譯bitcoin客戶端
編譯指令碼samplebuild.sh的程式碼,請修改DEPEND_HOME變數
export DEPEND_HOME=/d/cifs/try/buildbtc/csdn/bitcoin/3rd
./configure \
--disable-tests \
--with-boost="${DEPEND_HOME}/boost-1.50.0-mgw" \
--with-miniupnpc=yes \
CPPFLAGS="-D_WIN32_WINNT=0x0601 -DWINVER=0x0601 -w -g -O0 -I${DEPEND_HOME}/db-4.8.30.NC-mgw/include -I${DEPEND_HOME}/miniupnpc-1.6-mgw/include -I${DEPEND_HOME}/openssl-1.0.1c-mgw/include -I${DEPEND_HOME}/boost-1.50.0-mgw/include/boost-1_50" \
LDFLAGS="-L${DEPEND_HOME}/db-4.8.30.NC-mgw/lib -L${DEPEND_HOME}/miniupnpc-1.6-mgw/lib -L${DEPEND_HOME}/openssl-1.0.1c-mgw/lib"
4.1) 解決::UnRegisterSleepEx()錯誤
新增 -D_WIN32_WINNT=0x0601 -DWINVER=0x0601
4.2) 解決WSAPOLLFD未定義
在mingw的winsock2.h裡面的第912行附近新增
typedef struct pollfd {
SOCKET fd;
short events;
short revents;
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
4.3) 解決boost連線問題
4.3.1) boost_program_options
檢視src/m4/ax_boost_program_options.m4的第74行附近:
for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.dylib* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.dylib.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.a.*$;\1;'` ; do
修改為:
for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.dylib* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.dylib.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.dll.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.dll\.a.*$;\1;'` ; do
4.3.2) boost_chrono
檢視src/m4/ax_boost_chrono.m4的第81行附近:
for libextension in `ls $BOOSTLIBDIR/libboost_chrono*.so* $BOOSTLIBDIR/libboost_chrono*.dylib* $BOOSTLIBDIR/libboost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_chrono.*\)\.so.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.a.*$;\1;'` ; do
修改為:
for libextension in `ls $BOOSTLIBDIR/libboost_chrono*.so* $BOOSTLIBDIR/libboost_chrono*.dylib* $BOOSTLIBDIR/libboost_chrono*.dll.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_chrono.*\)\.so.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.dll\.a.*$;\1;'` ; do
4.4) 修復bitcoin構建時的庫依賴順序
libbitcoin_wallet.a依賴於boost的filesystem,但是在src/Makefile.am裡面boost_libs設定在libbitcoin_wallet.a之前,但是如果--disable-wallet編譯不發現問題。
5) 編譯核心模組bitcoind
sh autogen.sh && sh samplebuild.sh && make
$ make
...//很多輸出
CXXLD bitcoind.exe
CXX bitcoin-cli.o
CXXLD bitcoin-cli.exe
make[3]: Leaving directory `/d/cifs/try/buildbtc/csdn/bitcoin/bitcoin-master/src'
make[2]: Leaving directory `/d/cifs/try/buildbtc/csdn/bitcoin/bitcoin-master/src'
make[1]: Leaving directory `/d/cifs/try/buildbtc/csdn/bitcoin/bitcoin-master/src'
make[1]: Entering directory `/d/cifs/try/buildbtc/csdn/bitcoin/bitcoin-master'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/d/cifs/try/buildbtc/csdn/bitcoin/bitcoin-master'
執行命令列版本的bitcoin的client,看看幫助提示:
$ ./bitcoin-cli.exe --help
Bitcoin RPC client version v0.8.2-820-gf65dc44-dirty-beta
Usage:
bitcoin-cli [options] <command> [params] Send command to Bitcoin server
bitcoin-cli [options] help List commands
bitcoin-cli [options] help <command> Get help for a command
Options:
-? This help message
-conf=<file> Specify configuration file (default: bitcoin.conf)
-datadir=<dir> Specify data directory
-testnet Use the test network
-rpcconnect=<ip> Send commands to node running on <ip> (default: 127.0.0
.1)
-rpcwait Wait for RPC server to start
-rpcuser=<user> Username for JSON-RPC connections
-rpcpassword=<pw> Password for JSON-RPC connections
-rpcport=<port> Connect to JSON-RPC on <port> (default: 8332 or testnet
: 18332)
SSL options: (see the Bitcoin Wiki for SSL setup instructions)
-rpcssl Use OpenSSL (https) for JSON-RPC conn
ections
6) 編譯qt前端
構建好以後放到3rd目錄下備用。
另外下載google的protocbuf工具編譯後,放到3rd目錄下。
樓主會在git上push所有的需要的lib和工具到3rd目錄,包括打包用的makensis工具。
好了吧,開始配置帶qt前端的bticoin。
示例指令碼:samplebuild.sh
export MAKENSIS_HOME=/d/cifs/lab/csdn/bitcoin/3rd/nsis-2.46
export PROTOC_BIN_HOME=/d/cifs/lab/csdn/bitcoin/3rd/google-protoc-2.5-mgw/bin
export PROTOC_INC_HOME=/d/cifs/lab/csdn/bitcoin/3rd/google-protoc-2.5-mgw/include
export PROTOC_LIB_HOME=/d/cifs/lab/csdn/bitcoin/3rd/google-protoc-2.5-mgw/lib
export QT_BIN_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/bin
export QT_LIB_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/lib
export QT_INC_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/include
export QT_PLUGIN_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/plugins
export LANG_CODECS_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/plugins/codecs
export DEPEND_HOME=/d/cifs/lab/csdn/bitcoin/3rd
export PATH=$PATH:$MAKENSIS_HOME
./configure \
--disable-tests \
--disable-ipv6 \
--disable-ccache \
--with-boost="${DEPEND_HOME}/boost-1.50.0-mgw" \
--with-miniupnpc=yes \
--with-qt-incdir=${QT_INC_HOME} \
--with-qt-libdir=${QT_LIB_HOME} \
--with-qt-bindir=${QT_BIN_HOME} \
--with-qt-plugindir=${QT_PLUGIN_HOME} \
--with-protoc-bindir=${PROTOC_BIN_HOME} \
CPPFLAGS="-D_WIN32_WINNT=0x0601 -DWINVER=0x0601 -w -g -O0 -I${PROTOC_INC_HOME} -I${DEPEND_HOME}/db-4.8.30.NC-mgw/include -I${DEPEND_HOME}/miniupnpc-1.6-mgw/include -I${DEPEND_HOME}/openssl-1.0.1c-mgw/include -I${DEPEND_HOME}/boost-1.50.0-mgw/include/boost-1_50" \
LDFLAGS="-L${PROTOC_LIB_HOME}-L${LANG_CODECS_HOME} -L${DEPEND_HOME}/db-4.8.30.NC-mgw/lib -L${DEPEND_HOME}/miniupnpc-1.6-mgw/lib -L${DEPEND_HOME}/openssl-1.0.1c-mgw/lib"
樓主沒有打算使用pkg_config。有興趣的同學可以試試。
如果需要二維碼支援,請使用這個sh samplebuild.sh
export MAKENSIS_HOME=/d/cifs/lab/csdn/bitcoin/3rd/nsis-2.46
export PROTOC_BIN_HOME=/d/cifs/lab/csdn/bitcoin/3rd/google-protoc-2.5-mgw/bin
export PROTOC_INC_HOME=/d/cifs/lab/csdn/bitcoin/3rd/google-protoc-2.5-mgw/include
export PROTOC_LIB_HOME=/d/cifs/lab/csdn/bitcoin/3rd/google-protoc-2.5-mgw/lib
export QT_BIN_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/bin
export QT_LIB_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/lib
export QT_INC_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/include
export QT_PLUGIN_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/plugins
export QR_INC_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qrencode-3.4.3/include
export QR_LIB_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qrencode-3.4.3/lib
export LANG_CODECS_HOME=/d/cifs/lab/csdn/bitcoin/3rd/qt-4.8.5-mingw32-4.8.1/plugins/codecs
export DEPEND_HOME=/d/cifs/lab/csdn/bitcoin/3rd
export PATH=$PATH:$MAKENSIS_HOME
./configure \
--disable-tests \
--disable-ipv6 \
--disable-ccache \
--with-boost="${DEPEND_HOME}/boost-1.50.0-mgw" \
--with-miniupnpc=yes \
--with-qt-incdir=${QT_INC_HOME} \
--with-qt-libdir=${QT_LIB_HOME} \
--with-qt-bindir=${QT_BIN_HOME} \
--with-qt-plugindir=${QT_PLUGIN_HOME} \
--with-protoc-bindir=${PROTOC_BIN_HOME} \
QR_LIBS="-lqrencode" \
CPPFLAGS="-D_WIN32_WINNT=0x0601 -DWINVER=0x0601 -w -g -O0 -I${QR_INC_HOME} -I${PROTOC_INC_HOME} -I${DEPEND_HOME}/db-4.8.30.NC-mgw/include -I${DEPEND_HOME}/miniupnpc-1.6-mgw/include -I${DEPEND_HOME}/openssl-1.0.1c-mgw/include -I${DEPEND_HOME}/boost-1.50.0-mgw/include/boost-1_50" \
LDFLAGS="-L${QR_LIB_HOME} -L${PROTOC_LIB_HOME} -L${LANG_CODECS_HOME} -L${DEPEND_HOME}/db-4.8.30.NC-mgw/lib -L${DEPEND_HOME}/miniupnpc-1.6-mgw/lib -L${DEPEND_HOME}/openssl-1.0.1c-mgw/lib"
然後再來一個make吧(mingw32-make可能會有CreateProcess失敗的提示,linux和windows的路徑的問題)
耐心的等待吧,時間還好,比qt4的構建時間短多了。
執行make deploy可以生成一個安裝包,前提是你配置了了makensis打包軟體。
並且需要修改一下share/setup.nsi裡面的幾個linux路徑為windows路徑, 主要是File指令後面的引數。
安裝吧,安裝完成以後需要新增幾個依賴的dll到安裝目錄,boost, miniupnpc, berkeley db, protocbuf, 以及mingw的crt等。
Done!
7) 注意事項
1) boost
1) GCC 4.8 warns of ignored attribute in declaration
2)MINGW構建boost失敗
3) 匯出common_config_file_iterator
2) MiniUPNPc
建議使用最新的1.9版本以上,已經修復以下幾個1.6版本的問題:
1) 修改Makefile.mingw
這個是patch檔案, 新增del 命令定義,新增-Wl,字首
需要修改-enable-stdcall-fixup為-Wl,-enable-stdcall-fixup:
否則-enable-stdcall-fixup的-e會被理解成windows上可執行檔案的入口指令,這應該是編譯器的一個bug。
謝謝 steking1 同學的提醒
--- D:/cifs/lab/tarballs/Makefile.mingw 週二 四月 19 04:05:38 2011
+++ D:/cifs/lab/tarballs/Makefile.mingw.fixed 週二 二月 25 10:44:20 2014
@@ -8,6 +8,7 @@ CC = gcc
#CFLAGS = -Wall -g -DDEBUG -D_WIN32_WINNT=0X501
CFLAGS = -Wall -Os -DNDEBUG -D_WIN32_WINNT=0X501
LDLIBS = -lws2_32 -liphlpapi
+DEL = rm -rf
# -lwsock32
# -liphlpapi is used for GetBestRoute()
PYTHON=\utils\python25\python
@@ -23,11 +24,11 @@ init:
echo init > init
clean:
- del upnpc testminixml *.o
- del dll\*.o
- del *.exe
- del miniupnpc.dll
- del libminiupnpc.a
+ $(DEL) upnpc testminixml *.o
+ $(DEL) dll\*.o
+ $(DEL) *.exe
+ $(DEL) miniupnpc.dll
+ $(DEL) libminiupnpc.a
libminiupnpc.a: $(OBJS)
$(AR) cr [email protected] $?
@@ -58,10 +59,10 @@ upnpc.o:
$(CC) $(CFLAGS) -c -o dll/[email protected] $<
upnpc-static: upnpc.o libminiupnpc.a
- $(CC) -enable-stdcall-fixup -o [email protected] $^ $(LDLIBS)
+ $(CC) -Wl,-enable-stdcall-fixup -o [email protected] $^ $(LDLIBS)
upnpc-shared: dll/upnpc.o miniupnpc.lib
- $(CC) -enable-stdcall-fixup -o [email protected] $^ $(LDLIBS)
+ $(CC) -Wl,-enable-stdcall-fixup -o [email protected] $^ $(LDLIBS)
wingenminiupnpcstrings: wingenminiupnpcstrings.o
2) 從DLL生成匯入lib庫的時候出錯
dllwrap -k --driver-name gcc \
--def miniupnpc.def \
--output-def miniupnpc.dll.def \
--implib miniupnpc.lib -o miniupnpc.dll \
dll/miniwget.o dll/minixml.o dll/igd_desc_parse.o dll/minisoap.o dll/min
iupnpc.o dll/upnpreplyparse.o dll/upnpcommands.o dll/upnperrors.o dll/connecthos
tport.o dll/portlistingparse.o dll/receivedata.o -lws2_32 -liphlpapi
D:\cifs\mingw32\bin\dlltool: Syntax error in def file miniupnpc.def:5
D:\cifs\mingw32\bin\dlltool: Syntax error in def file miniupnpc.def:5
看看def檔案的前面5行,dlltool工具不允許空的library指令,修改一下,在第一行LIBRARY指令後面新增一下庫的名字miniupnpc:
LIBRARY miniupnpc
; miniupnpc library
EXPORTS
; miniupnpc
3) BerkeleyDB
可以考慮直接禁用repmgr模組 --disable-replication,因為這個模組依賴依賴posix的一些系統api,mingw支援不好。
# Replication can be disabled.
if test "$db_cv_build_replication" = "yes"; then
AC_DEFINE(HAVE_REPLICATION)
AH_TEMPLATE(HAVE_REPLICATION,
[Define to 1 if building replication support.])
ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(REP_OBJS)"
# If we're building replication and detected POSIX threads, build the
# replication manager.
AH_TEMPLATE(HAVE_REPLICATION_THREADS,
[Define to 1 if building the Berkeley DB replication framework.])
if test "$ac_cv_header_pthread_h" = yes; then
AC_DEFINE(HAVE_REPLICATION_THREADS)
# Solaris requires the socket and nsl libraries to build the
# replication manager. Don't add nsl regardless of the OS,
# it causes RPC to fail on AIX 4.3.3.
case "$host_os" in
solaris*)
AC_HAVE_LIBRARY(nsl, LIBSO_LIBS="$LIBSO_LIBS -lnsl")
AC_HAVE_LIBRARY(socket,
LIBSO_LIBS="$LIBSO_LIBS -lsocket");;
esac
ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(REPMGR_OBJS)"
else
ADDITIONAL_OBJS="$ADDITIONAL_OBJS repmgr_stub${o}"
fi
else
ADDITIONAL_OBJS="$ADDITIONAL_OBJS rep_stub${o} repmgr_stub${o}"
fi
4) mingw32在linux交叉編譯openssl
5) 自動指令碼
for windows native building with mingw64, with GUI, used for client
# 1) zlib
make install -f win32/Makefile.gcc \
DESTDIR=/usr/local/zlib-1.2.8/ \
INCLUDE_PATH=include \
LIBRARY_PATH=lib \
BINARY_PATH=bin
# 2) libpng
./configure --prefix=/usr/local/libpng-1.6.9 \
--enable-shared=no \
--enable-static=yes
# 3) qrencode
./configure --prefix=/usr/local/qrencode-3.4.3 \
--enable-shared=no \
--enable-static=yes \
png_CFLAGS="-I/usr/local/libpng-1.6.9/include" \
png_LIBS="-L/usr/local/libpng-1.6.9/lib -lpng16"
# 4) protobuf
./configure --prefix=/usr/local/protobuf-2.5.0 \
--enable-static=yes \
--enable-shared=no
# 5) BerkeleyDB
cd build_unix && sh ../dist/configure \
--enable-mingw \
--enable-cxx \
--disable-replication
# 6) miniupnpc
make -f Makefile.mingw && mkdir miniupnpc && cp *.h miniupnpc
# 7) OpenSSL
./config \
no-shared \
no-threads \
no-asm \
no-zlib \
--prefix=/usr/local/ssl \
&& make && make install
# 8) Boost
b2 install --prefix=/usr/local/boost-1.53 \
toolset=gcc \
link=shared \
variant=release \
runtime-link=shared \
threading=multi \
--without-mpi \
--without-python \
--without-wave \
--without-graph \
--without-graph_parallel
# 9) qt4
configure.exe \
-I "/usr/local/ssl/include" \
-L "/usr/local/ssl/lib" \
-l ssl \
-l crypto \
-release \
-opensource \
-confirm-license \
-static \
-no-ltcg \
-no-fast \
-exceptions \
-accessibility \
-stl \
-no-sql-sqlite \
-no-qt3support \
-no-opengl \
-no-openvg \
-platform win32-g++ \
-no-system-proxies \
-qt-zlib \
-no-gif \
-qt-libpng \
-no-libmng \
-no-libtiff \
-qt-libjpeg \
-no-dsp \
-no-vcproj \
-no-incredibuild-xge \
-plugin-manifests \
-qmake \
-process -nomake demos -nomake examples -nomake tools \
-no-rtti \
-no-mmx \
-no-3dnow \
-no-sse \
-no-sse2 \
-openssl \
-no-dbus \
-no-phonon -no-phonon-backend \
-no-multimedia -no-audio-backend \
-no-webkit \
-no-script -no-scripttools -no-declarative \
-arch windows \
-no-style-plastique \
-no-style-windowsxp -no-style-windowsvista \
-no-style-cleanlooks -no-style-cde \
-no-style-motif \
-no-native-gestures \
-saveconfig csdnbuild
# 10)
export DEPEND_HOME=/usr/local
export MAKENSIS_HOME=${DEPEND_HOME}/nsis-2.46
export BDB_INC_HOME=${DEPEND_HOME}/BerkeleyDB.4.8/include
export BDB_LIB_HOME=${DEPEND_HOME}/BerkeleyDB.4.8/lib
export BOOST_TOP_HOME=${DEPEND_HOME}/boost-1.55
export BOOST_INC_HOME=${DEPEND_HOME}/boost-1.55/include/boost-1_55
export BOOST_LIB_HOME=${DEPEND_HOME}/boost-1.55/lib
export PNG_INC_HOME=${DEPEND_HOME}/libpng-1.6.9/include
export PNG_LIB_HOME=${DEPEND_HOME}/libpng-1.6.9/lib
export MINIUPNPC_INC_HOME=${DEPEND_HOME}/miniupnpc-1.9.0/include
export MINIUPNPC_LIB_HOME=${DEPEND_HOME}/miniupnpc-1.9.0/lib
export PROTOC_BIN_HOME=${DEPEND_HOME}/protobuf-2.5.0/bin
export PROTOC_INC_HOME=${DEPEND_HOME}/protobuf-2.5.0/include
export PROTOC_LIB_HOME=${DEPEND_HOME}/protobuf-2.5.0/lib
export QR_INC_HOME=${DEPEND_HOME}/qrencode-3.4.3/include
export QR_LIB_HOME=${DEPEND_HOME}/qrencode-3.4.3/lib
export QT_BIN_HOME=${DEPEND_HOME}/qt-4.8.5-mingw32-4.8.1/bin
export QT_INC_HOME=${DEPEND_HOME}/qt-4.8.5-mingw32-4.8.1/include
export QT_LIB_HOME=${DEPEND_HOME}/qt-4.8.5-mingw32-4.8.1/lib
export QT_PLUGIN_HOME=${DEPEND_HOME}/qt-4.8.5-mingw32-4.8.1/plugins
export QT_CODECS_HOME=${DEPEND_HOME}/qt-4.8.5-mingw32-4.8.1/plugins/codecs
export SSL_INC_HOME=${DEPEND_HOME}/ssl/include
export SSL_LIB_HOME=${DEPEND_HOME}/ssl/lib
export CRYPTO_INC_HOME=${DEPEND_HOME}/ssl/include
export CRYPTO_LIB_HOME=${DEPEND_HOME}/ssl/lib
export ZLIB_INC_HOME=${DEPEND_HOME}/zlib-1.2.8/include
export ZLIB_LIB_HOME=${DEPEND_HOME}/zlib-1.2.8/lib
export PATH=${PATH}:${MAKENSIS_HOME}
./configure \
--enable-wallet \
--disable-tests \
--disable-ipv6 \
--disable-ccache \
--with-boost="${BOOST_TOP_HOME}" \
--with-qrencode=yes \
--with-miniupnpc=yes \
--with-protoc-bindir=${PROTOC_BIN_HOME} \
--with-cli=yes \
--with-daemon=yes \
--with-gui=qt4 \
--with-qt-incdir=${QT_INC_HOME} \
--with-qt-libdir=${QT_LIB_HOME} \
--with-qt-bindir=${QT_BIN_HOME} \
--with-qt-plugindir=${QT_PLUGIN_HOME} \
CPPFLAGS="-w -g -O0 -I${QR_INC_HOME} -I${PNG_INC_HOME} -I${PROTOC_INC_HOME} -I${SSL_INC_HOME} -I${CRYPTO_INC_HOME} -I${BDB_INC_HOME} -I${MINIUPNPC_INC_HOME} -I${BOOST_INC_HOME} -I${ZLIB_INC_HOME}" \
LDFLAGS="-L${QR_LIB_HOME} -L${QT_CODECS_HOME} -L${PNG_LIB_HOME} -L${PROTOC_LIB_HOME} -L${SSL_LIB_HOME} -L${CRYPTO_LIB_HOME} -L${BDB_LIB_HOME} -L${MINIUPNPC_LIB_HOME} -L${ZLIB_LIB_HOME}"
for linux native building with gcc, without gui, used for mining and service.
# 1) Boost
./b2 install --prefix=/root/harrywu/build/3rd/boost toolset=gcc variant=release link=static threading=multi runtime-link=static --without-graph --without-graph_parallel --without-mpi --without-python --without-regex --without-wave
# 2) BerkeleyDB
cd build_unix && ../dist/configure --prefix=/root/harrywu/build/3rd/bdb48 --enable-static=yes --enable-shared=no --enable-cxx --disable-replication --disable-debug
# 3) miniupnpc
make DESTDIR=/root/harrywu/build/3rd/miniupnpc-1.9.0 INSTALLPREFIX= install
# 4) protobuf
./configure --prefix=/root/harrywu/build/3rd/protobuf-2.5.0 --enable-shared=no --enable-static=yes CPPFLAGS=-I/root/harrywu/build/3rd/zlib-1.2.8/include/ LDFLAGS=-L/root/harrywu/build/3rd/zlib-1.2.8/lib LIBS=-lz
# 5) qrencode
./configure --prefix=/root/harrywu/build/3rd/qrencode-3.4.3 --enable-shared=no --enable-static=yes png_CFLAGS=-I/root/harrywu/build/3rd/libpng-1.6.10/ png_LIBS=-L/root/harrywu/build/3rd/libpng-1.6.10/lib/ -lpng16
# 6) ssl
./config no-threads no-shared no-zlib no-asm --prefix=/root/harrywu/build/3rd/ssl
# 7) zlib
./configure --prefix=/root/harrywu/build/3rd/zlib-1.2.8 --static
# 8) libpng
./configure --prefix=/root/harrywu/build/3rd/libpng-1.6.10 --enable-shared=no --enable-static=yes CPPFLAGS=-I/root/harrywu/build/3rd/zlib-1.2.8/include/ LDFLAGS=-L/root/harrywu/build/3rd/zlib-1.2.8/lib LIBS=-lz
# 9) qt missing
# 10) Bitcoin
export DEPEND_HOME=/root/harrywu/build/3rd
export BDB_INC_HOME=${DEPEND_HOME}/BerkeleyDB-4.8.0/include
export BDB_LIB_HOME=${DEPEND_HOME}/BerkeleyDB-4.8.0/lib
export BOOST_TOP_HOME=${DEPEND_HOME}/boost-1.53
export BOOST_INC_HOME=${DEPEND_HOME}/boost-1.53/include/boost-1_55
export BOOST_LIB_HOME=${DEPEND_HOME}/boost-1.53/lib
export PNG_INC_HOME=${DEPEND_HOME}/libpng-1.6.10/include
export PNG_LIB_HOME=${DEPEND_HOME}/libpng-1.6.10/lib
export MINIUPNPC_INC_HOME=${DEPEND_HOME}/miniupnpc-1.9.0/include
export MINIUPNPC_LIB_HOME=${DEPEND_HOME}/miniupnpc-1.9.0/lib
export PROTOC_BIN_HOME=${DEPEND_HOME}/protobuf-2.5.0/bin
export PROTOC_INC_HOME=${DEPEND_HOME}/protobuf-2.5.0/include
export PROTOC_LIB_HOME=${DEPEND_HOME}/protobuf-2.5.0/lib
export QR_INC_HOME=${DEPEND_HOME}/qrencode-3.4.3/include
export QR_LIB_HOME=${DEPEND_HOME}/qrencode-3.4.3/lib
export SSL_INC_HOME=${DEPEND_HOME}/ssl/include
export SSL_LIB_HOME=${DEPEND_HOME}/ssl/lib
export CRYPTO_INC_HOME=${DEPEND_HOME}/ssl/include
export CRYPTO_LIB_HOME=${DEPEND_HOME}/ssl/lib
export ZLIB_INC_HOME=${DEPEND_HOME}/zlib-1.2.8/include
export ZLIB_LIB_HOME=${DEPEND_HOME}/zlib-1.2.8/lib
./configure \
--enable-wallet \
--disable-tests \
--disable-ipv6 \
--disable-ccache \
--with-boost="${BOOST_TOP_HOME}" \
--with-qrencode=yes \
--with-miniupnpc=yes \
--with-protoc-bindir=${PROTOC_BIN_HOME} \
--with-cli=yes \
--with-daemon=yes \
--with-gui=no \
CPPFLAGS="-I${QR_INC_HOME} -I${PNG_INC_HOME} -I${PROTOC_INC_HOME} -I${SSL_INC_HOME} -I${CRYPTO_INC_HOME} -I${BDB_INC_HOME} -I${MINIUPNPC_INC_HOME} -I${BOOST_INC_HOME} -I${ZLIB_INC_HOME}" \
LDFLAGS="-L${QR_LIB_HOME} -L${PNG_LIB_HOME} -L${PROTOC_LIB_HOME} -L${SSL_LIB_HOME} -L${CRYPTO_LIB_HOME} -L${BDB_LIB_HOME} -L${MINIUPNPC_LIB_HOME} -L${ZLIB_LIB_HOME}" \
LIBS="-lrt -ldl"