网赚论坛

 找回密码
 免费注册
查看: 292|回复: 0
打印 上一主题 下一主题

在Windows下 搭建山寨币 制造山寨币 教你怎么制作比特币

[复制链接]

17

主题

22

帖子

68

积分

Ⅰ级财主

Rank: 1

积分
68
跳转到指定楼层
楼主
发表于 2017-11-21 00:47:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
编译方法
——————————————————————————————————➤➤➤➤➤➤
——————————————————————————————————➤➤➤➤➤➤
Windows系统 ➤➤➤➤➤➤本例64位系统,安装32位工具

【Windows7/8 32/64bit】

➤》》》》MinGW单独安装
http://www.mingw.org/ 【Windows平台得力工具 C语言编译器】
http://sourceforge.net/projects/mingw/files/
http://sourceforge.net/projects/mingw-w64/
http://nuwen.net/mingw.html
http://sourceforge.net/projects/mingw/files/Installer/
下载最新版

###安装过程中,选择第二项:【Download latest repository catalogues 】gcc版本4.7.2
###安装目录D:MinGW

http://sourceforge.net/projects/mingwbuilds/
http://sourceforge.net/projects/msys2/
http://sourceforge.net/projects/mingwbuilds/files/latest/download
gcc-4.8.1-x32-win32-dwarf-rev2 works
默认安装目录C:Program Files (x86)mingw-buildsx32-4.8.1-win32-dwarf-rev2
修改安装目录D:MinGW


(编译比特币,gcc 4.6.2 到 4.7.2 不工作)安装过程中,选择第一项:【Use pre-packaged repository catalogues 20111118】gcc版本4.6.1
http://sourceforge.net/projects/ ... wnload?source=files
http://bbs.73yi.net/thread-502-1-1.html

最小化安装,"C Compiler"、"C++ Compiler""MSYS Basic System" 是需要安装的,这里就全部安装上
安装目录D:MinGW

Git【非必须安装,跳过,自己若有需要就安装】
http://bbs.73yi.net/thread-2068-1-1.html
http://bbs.73yi.net/thread-2071-1-1.html


安装ActivePerl Community Edition
http://www.activestate.com/activeperl/downloads
【使用这个32位的吧,64位的也可以】http://downloads.activestate.com ... in32-x86-296746.msi
【这是64位系统的】http://downloads.activestate.com ... in32-x64-296746.msi
安装的时候,可以排除Perl Script、PPM、documentation 和 examples(如果你不需要它们)
安装目录D:Perl
其余默认,安装完成

运行MinGW Shell(msys)以后命令都在这里运行
D:MinGWmsys1.0msys.bat
#D:MinGWmingwbuilds.bat

执行命令:
#/d/MinGW/bin/mingw-get install msys-perl
mingw-get install msys-perl
将从sourceforge上下载4个组件,并且自动安装

添加MinGW bin 目录到 PATH environment variable (D:MinGWbin if you used installer defaults).
系统属性》高级》环境变量
变量名PATH
变量值D:MinGWbin;%PATH%
##变量值D:MinGWmsys1.0bin;D:MinGWbin;%PATH%
#变量值D:MinGWmingw32bin;%PATH%


➤》》》》openssl http://www.openssl.org/source/
http://slproweb.com/products/Win32OpenSSL.html
Win32 OpenSSL v1.0.1e Light
http://slproweb.com/download/Win32OpenSSL_Light-1_0_1e.exe
Win32 OpenSSL v1.0.1e
http://slproweb.com/download/Win32OpenSSL-1_0_1e.exe
Win64 OpenSSL v1.0.1e Light
http://slproweb.com/download/Win64OpenSSL_Light-1_0_1e.exe
Win64 OpenSSL v1.0.1e
http://slproweb.com/download/Win64OpenSSL-1_0_1e.exe

【下载】http://www.openssl.org/source/openssl-1.0.1e.tar.gz

建立一个批处理:D:a.bat
echo off
echo 开 始 编 译 测 试...
set PATH=D:MinGWmsys1.0bin;D:MinGWbin;D:Qt4.8.5qmake;D:Qt4.8.5bin;%PATH%
cd /D D:MinGWmsys1.0


msys.bat窗口中执行命令:
cd /d/openssl-1.0.1e
#sh ..openssl-1.0.1econfig --enable-mingw --enable-cxx CFLAGS="-I$MINGW_PREFIXinclude"
#D:MinGWmsys1.0binsh.exe D:openssl-1.0.1eConfigure --enable-mingw --enable-cxx CFLAGS="-I$MINGW_PREFIXinclude"
#sh D:openssl-1.0.1econfig
#sh config
./config enable-mingw enable-cxx
make
生成的libcrypto.a和libssl.a位于D:openssl-1.0.1e



➤》》》》Berkeley DB db-4.8.30.
http://www.oracle.com/technetwor ... ownloads/index.html
http://www.oracle.com/technetwor ... ownloads/index.html
http://download.oracle.com/otn/berkeley-db/db-5.3.21.NC.tar.gz【需要注册登录方可下载】
http://sources.buildroot.net/
http://sources.buildroot.net/db-5.3.21.NC.tar.gz
【下载这个】http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
https://edelivery.oracle.com/aka ... db-5.3.21.NC.tar.gz
http://download.oracle.com/otn/berkeley-db/db-5.3.21.NC.zip【需要注册登录方可下载】
https://edelivery.oracle.com/aka ... db/db-5.3.21.NC.zip

http://www.oracle.com/technetwor ... dex-086374-zhs.html
http://download.oracle.com/berkeley-db/db-4.8.30.msi
http://download.oracle.com/otn/berkeley-db/db-5.2.36.msi【需要注册登录方可下载】

++++【这里跳过,不用这种方式】Visual C++编译方法:
http://sources.buildroot.net/db-5.3.21.NC.tar.gz
Visual C++ .NET 2010
1 Choose File -> Open -> Project/Solution.... In the build_windows directory, select Berkeley_DB_vs2010.sln and click Open.
2 Choose the desired project configuration from the drop-down menu on the tool bar (either Debug or Release).
3 Choose the desired platform configuration from the drop-down menu on the tool bar (usually Win32 or x64).
4 To build, right-click on the Berkeley_DB_vs2010 solution and select Build Solution.


+++++【使用这种方式编译】MinGW编译方法:
msys.bat窗口中执行命令:
cd /d/db-4.8.30.NC/build_unix
../dist/configure --enable-mingw --enable-cxx
#sh ../dist/configure --disable-replication --enable-mingw --enable-cxx
#sh ..db-4.8.30.NCdistconfigure --enable-mingw --enable-cxx CFLAGS="-I..MinGWinclude" --disable-replication
#sh ..db-4.8.30.NCdistconfigure --enable-mingw --enable-cxx CFLAGS="-I$MINGW_PREFIXinclude"
#sh ..db-4.8.30.NCdistconfigure --enable-mingw --enable-cxx --host="$MINGW_BASENAME" CFLAGS="-I$MINGW_PREFIX/include"
#D:MinGWmsys1.0binsh.exe D:db-4.8.30.NCdistconfigure --enable-mingw --enable-cxx

configure: WARNING: Neither mmap/munmap(2) or shmget(2) library functions.
config.log

#编辑D:db-4.8.30.NCbuild_unixdb.h
113行:
typedef pthread_t db_threadid_t;
修改为
typedef u_int32_t db_threadid_t;

make

生成文件位于:
D:db-4.8.30.NCbuild_unix
D:db-4.8.30.NCbuild_unix.libs


【忽略】
http://code.google.com/p/leveldb/
https://code.google.com/p/leveldb/
http://code.google.com/p/leveldb/downloads/list
https://code.google.com/p/leveldb/downloads/list
http://leveldb.googlecode.com/files/leveldb-1.12.0.tar.gz

【忽略】
使用Qt提供的命令行,
cd /d/leveldb-1.12.0
TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a
获得libleveldb.a和libmemenv.a

【忽略】
可以在linux系统下进行编译:
cd /tmp
wget http://leveldb.googlecode.com/files/leveldb-1.12.0.tar.gz
tar zxvf leveldb-1.12.0.tar.gz
cd leveldb-1.12.0
make libleveldb.a libmemenv.a
make命令执行后,可以看到目录下有一个libleveldb.a和libmemenv.a文件,放入比特币源码目录,位置srcsrcleveldb


➤》》》》Boost C++ Libraries
http://www.boost.org/users/download/
http://www.boostpro.com/download/

http://www.highscore.de/cpp/boostbuild/
【下载这个】http://sourceforge.net/projects/boost/files/boost/1.54.0/
http://sourceforge.net/projects/boost/files/boost/1.50.0/
http://sourceforge.net/projects/ ... 1_50_0.zip/download
http://sourceforge.net/projects/boost/files/boost-jam/3.1.18/
http://sourceforge.net/projects/ ... 3.1.18.zip/download
http://sourceforge.net/projects/ ... -ntx86.zip/download
免编译直接下载

【忽略,这是VC++编译方法,这里不使用】
BoostPro Binary Installer for Visual C++
For users of Visual C++ 7.1 (Visual Studio 2003) (32-bit only), Visual C++ 8.0 (Visual Studio 2005), 9.0 (Visual Studio 2008), and 10.0 (Visual Studio 2010)—all with the latest service packs—we offer an installer that will place source, documentation, and compiled 32-bit and/or 64-bit library binaries on your system.

【还有这种方法,这里也不使用】
http://www.boostpro.com/download/
这个工具可以帮你下载并编译好,你只需要点击鼠标配置下就可以了,一步步操作,最后点击Install之后就会编译并安装到你指定的目录,因为是下载后编译,所以可能会有点慢

Microsoft Visual Studio 开发工具 下载:
http://bbs.73yi.net/thread-502-1-1.html

set PATH=E:编程开发工具VC2010bin
cd E:编程开发工具boost_1_54_0_beta1boost_1_50_0
E:编程开发工具boost_1_54_0_beta1boost_1_50_0bootstrap.bat msvc


【下面讲述使用MinGw来进行编译】:
https://github.com/bitcoin/bitcoin/issues/1964

编辑D:boost-jam-3.1.18build.bat
build.bat msvc
修改成build.bat gcc
bingcc.exe
修改相应路径
运行build.bat gcc
生成bjam.exe,位于bin.ntx86目录内


编辑 D:boost_1_54_0bootstrap.bat
找到 set toolset=msvc 修改设置 toolset=gcc
打开 D:boost_1_54_0toolsbuildv2enginebuild.bat 搜索 mingw
replace existing code with:
if EXIST "D:MinGWbingcc.exe" (
set "BOOST_JAM_TOOLSET=mingw"
set "BOOST_JAM_TOOLSET_ROOT=D:MinGW"
修改自己的mingw gcc路径

cmd窗口中运行脚本,D:a.bat
cd D:boost_1_54_0
运行:
#bootstrap.bat mingw
bootstrap.bat gcc
将建造bjam.exe、b2.exe,产生的文件位于 D:boost_1_54_0
toolsbuildv2enginebin.ntx86bjam.exe
toolsbuildv2enginebin.ntx86b2.exe


cmd窗口中运行脚本,D:a.bat
cd D:boost_1_54_0
#bjam toolset=gcc --build-type=complete stage
bjam toolset=gcc --build-type=complete stage --with-chrono --with-filesystem --with-program_options --with-system --with-thread
#b2 toolset=gcc --build-type=complete stage --with-chrono --with-filesystem --with-program_options --with-system --with-thread


将创建比特币所需要的所有*.a文件,位于:
D:boost_1_54_0bin.v2
D:boost_1_54_0stage

D:boost_1_54_0stagelib中的文件,在具体的makefile文件中进行引用。


题外操作(与编译比特币无关):
bjam --show-libraries
显示可以编译安装的boost包

bjam stage toolset=gcc --build-dir=build --build-type=complete --with-date_time --with-graph --with-graph_parallel --with-random
编译

bjam install toolset=gcc --prefix=BOOST-INST --with-date_time --with-graph --with-graph_parallel --with-random
安装

—【忽略开始】———————————————————————————————————————————————
编辑 D:boost_1_54_0bootstrap.bat
找到 set toolset=msvc 修改设置 toolset=gcc
打开 D:boost_1_54_0toolsbuildv2enginebuild.bat 搜索 mingw
replace existing code with:
if EXIST "D:MinGWbingcc.exe" (
set "BOOST_JAM_TOOLSET=mingw"
set "BOOST_JAM_TOOLSET_ROOT=D:MinGW"
修改自己的mingw gcc路径

从Windows系统cmd窗口中运行:D:a.bat
cd D:boost_1_54_0
bootstrap.bat mingw
b2 --build-type=complete --with-chrono --with-filesystem --with-program_options --with-system --with-thread toolset=gcc stage

将创建比特币所需要的所有*.a文件,位于:
D:boost_1_54_0bin.v2
D:boost_1_54_0stage

D:boost_1_54_0stagelib中的文件,在具体的makefile文件中进行引用。
—【忽略结束】———————————————————————————————————————————————

【忽略,上一步b2命令和这里只是参数不同,采用上一种方式】创建比特币需要的库:
b2 --toolset=gcc --build-dir=D:boost_1_50_0 --build-type=minimal stage link=static runtime-link=static threading=multi variant=release -a -j 4 --with-filesystem --with-program_options --with-system --with-thread


将创建比特币所需要的所有*.a文件,位于:
D:boost_1_50_0boostbin.v2
D:boost_1_50_0boostbin.v2libsthreadbuildgcc-mingw-4.7.2releaselink-staticruntime-link-staticthreading-multi
D:boost_1_50_0boostbin.v2libssystembuildgcc-mingw-4.7.2releaselink-staticruntime-link-staticthreading-multi


➤》》》》MiniUPnP
http://miniupnp.tuxfamily.org/files/
http://miniupnp.free.fr/files/
http://miniupnp.tuxfamily.org/fi ... -win32-20121009.zip
【下载】http://miniupnp.free.fr/files/do ... 1.8.20130503.tar.gz
不要下载miniupnpd
https://github.com/miniupnp/mini ... pnpc/Makefile.mingw

#cmd窗口中运行脚本,D:a.bat
cd D:miniupnpc-1.8.20130503
#mingw32make.bat
mingw32-make -f Makefile.mingw ADDITIONALCCFLAGS="%ADDITIONALCCFLAGS%"
mkdir miniupnpc
cp *.h miniupnpc/

Msys窗口中运行:
cd /d/miniupnpc-1.8.20130503
make -f Makefile.mingw
mkdir miniupnpc
cp *.h miniupnpc/


➤》》》》获取Bitcoin比特币源码:
https://github.com/bitcoin/bitcoin/archive/master.zip
【以此为例】https://github.com/bitcoin/bitcoin/tree/v0.8.3
https://github.com/bitcoin/bitcoin/archive/v0.8.3.zip
https://github.com/laanwj/bitcoin
这里下载Qt5.1分支
可以下载压缩包,也可以自己使用git客户端克隆

解压缩后,msys.bat窗口中进行:
cd /d/bitcoin-master/src/leveldb
TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a
此命令是编译bitcoin必须的libleveldb.a 和 libmemenv.a

编辑D:bitcoin-mastersrcmakefile.mingw
编辑BOOST_SUFFIX、INCLUDEPATHS 和 LIBPATHS
#DEPSDIR?=/usr/local
BOOST_SUFFIX?=-mgw47-mt-sd-1_54

INCLUDEPATHS=
-I"$(CURDIR)"
-I"d:/boost_1_54_0"
-I"d:/db-4.8.30.NC/build_unix"
-I"d:/openssl-1.0.1e/include"

LIBPATHS=
-L"$(CURDIR)/leveldb"
-L"d:/boost_1_54_0/stage/lib"
-L"d:/db-4.8.30.NC/build_unix"
-L"d:/openssl-1.0.1e"

LIBS=
-l leveldb
-l memenv
-l boost_system$(BOOST_SUFFIX)
-l boost_filesystem$(BOOST_SUFFIX)
-l boost_program_options$(BOOST_SUFFIX)
-l boost_thread$(BOOST_SUFFIX)
-l boost_chrono$(BOOST_SUFFIX)
-l db_cxx
-l ssl
-l crypto

DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
修改为:
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__NO_SYSTEM_INCLUDES

>>>再继续查找

ifndef USE_UPNP
override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
INCLUDEPATHS += -I"d:miniupnpc-1.8.20130503"【这一行新增加】
LIBPATHS += -L"d:miniupnpc-1.8.20130503"【这一行新增加】
LIBS += -l miniupnpc -l iphlpapi
DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP)
endif


【本例采用】考虑添加-static选项到LDFLAGS,如果你的机器上没有安装MinGW;如果编译不带-static选项,你将需要分发libgcc_s_dw2-1.dll和libstdc++-6.dll可执行文件。
代码:
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -Wl,--large-address-aware -static


在Windows cmd 窗口中运行:D:a.bat
cd D:bitcoin-mastersrc
mingw32-make -f makefile.mingw
strip bitcoind.exe



容易出现的情况:
ld.exe: cannot find -lcrypto
lcrypto位于openssl

leveldb.h:42: undefined reference to `leveldb::WriteBatch
recipe for target 'bitcoind.exe' failed

mingw32-make -i -f makefile.mingw

msys.bat窗口中运行:
cd /d/bitcoin-master/src/leveldb
TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a
#清理旧文件后,重新建造:
#TARGET_OS=NATIVE_WINDOWS make clean
cd ..
mingw32-make -f makefile.mingw
strip bitcoind.exe




D:miniupnpc-1.8.20130503
把miniupnpc目录复制到src目录下
不然编译bitcoin-qt时候会出现src/net.cpp错误,找不到miniupnpc/miniwget.h文件或者目录


➤》》》》QT完全安装不包含MinGW
http://qt-project.org/downloads
【下载最新版本】

http://download.qt-project.org/o ... rce-4.8.5-mingw.exe

完全安装,所有功能和组件,包含MinGW
There is a problem with your MinGW installation:
The installer could not find a valid d:MinGWincludew32api.h
(Only versions with W32API 3.13 are supported)
Do you still want to continue?(Your installation may not work)

#安装完成后,设置系统环境变量;系统属性》高级》环境变量;
#变量名:PATH
#变量值:
#D:MinGWmsys1.0bin;D:MinGWbin;D:Qt4.8.5qmake;D:Qt4.8.5bin;%PATH%


编辑D:bitcoin-masterbitcoin-qt.pro
# 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=-mgw46-mt-sd-1_54
BOOST_INCLUDE_PATH=D:boost_1_54_0
BOOST_LIB_PATH=D:boost_1_54_0stagelib
BDB_INCLUDE_PATH=D:db-4.8.30.NCbuild_unix
BDB_LIB_PATH=D:db-4.8.30.NCbuild_unix
OPENSSL_INCLUDE_PATH=D:openssl-1.0.1einclude
OPENSSL_LIB_PATH=D:openssl-1.0.1e

【还有原来的一行,全部内容是一整行】
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


打开开始菜单上的Qt 4.8.5 Command Prompt
或者
cmd窗口中运行:d:Qt4.8.5binqtvars.bat
bat文件内容:
@echo off
rem
rem This file is generated
rem

echo Setting up a MinGW/Qt only environment...
echo -- QTDIR set to d:Qt4.8.5
echo -- PATH set to d:Qt4.8.5bin
echo -- Adding d:MinGWbin to PATH
echo -- Adding %SystemRoot%System32 to PATH
echo -- QMAKESPEC set to win32-g++

set QTDIR=d:Qt4.8.5
set PATH=d:Qt4.8.5bin
set PATH=%PATH%;d:MinGWbin
set PATH=%PATH%;%SystemRoot%System32
set QMAKESPEC=win32-g++

if not "%1"=="compile_debug" goto END
cd %QTDIR%
echo This will configure and compile qt in debug.
echo The release libraries will not be recompiled.
pause
configure -plugin-sql-sqlite -plugin-sql-odbc -qt-libpng -qt-libjpeg
cd %QTDIR%src
qmake
mingw32-make debug
:END


C:WindowsSystem32cmd.exe /A /Q /K D:QtQt5.1.05.1.0mingw48_32binqtenv2.bat
D:QtQt5.1.05.1.0mingw48_32binqtenv2.bat内容:
echo off
echo Setting up environment for Qt usage...
set PATH=D:QtQt5.1.05.1.0mingw48_32bin;d:QtQt5.1.0/Tools/mingw48_32bin;%PATH%
cd /D D:QtQt5.1.05.1.0mingw48_32


运行命令:
cd D:bitcoin-master
qmake "USE_UPNP=-"
mingw32-make -f Makefile.Release
【若出错执行:mingw32-make -f Makefile.Release clean】






编辑Makefile.Release
LIBS = -L"c:Qt4.8.4lib" -lmingwthrd -lmingw32 -lqtmain ...

LIBS = -L"c:Qt4.8.4bin" -L"c:Qt4.8.4lib" -lmingwthrd -lmingw32 -lqtmain ...


QMAKESPEC has not been set, so configuration cannot be deduced.
Error processing project file: bitcoin-qt.pro

【Windows下】
在环境变量(系统属性》高级》环境变量)加上:
#QMAKESPEC = win32-msvc2008
QMAKESPEC = win32-g++
QTDIR=D:Qt4.8.5bin
QMAKESPEC=D:Qt4.8.5mkspecs

【Linux下】
是QMAKESPEC环境变量没有设置好,在/root/.bash_profile里加入一行:
export QMAKESPEC=/usr/local/qt-x11-opensource-src-4.3.2/mkspecs/linux-g++(即是linux-g++的路径)。

http://blog.csdn.net/zhaole20094463/article/details/7261815




➤》》》》参考:
https://github.com/bitcoin/bitcoin/issues/1964

编译方法:
https://bitcointalk.org/index.php?topic=149479.0
https://bitcointalk.org/index.ph ... 6&topic=45507.0
https://bitcointalk.org/index.php?topic=252931
https://github.com/phelixbtc/bitcoin
https://github.com/phelixbtc/bit ... v0.1/easywinbuilder
https://bitcointalk.org/index.php?topic=28782.0
https://github.com/Alexpux/Qt-builds/


boost/algorlthm/string/classification.hpp: No such file or directory
编辑D:srcsrcalert.cpp
找到#include
将D:boost_1_50_0boost复制到D:srcsrc

openssl/crypto.h: No such file or directory
复制D:openssl-1.0.1eincludeopenssl到D:srcsrc

db_cxx.h: No such file or directory
进入D:db-5.3.21.NC
将db_cxx.h复制到D:srcsrc

复制D:miniupnpc-1.8.20130503miniupnpc到D:srcsrc
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

广告合作|Archiver|手机版|小黑屋|财富吧

GMT+8, 2026-7-18 17:47 , Processed in 0.390001 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.1

© 2014-2021 财富吧

快速回复 返回顶部 返回列表