比特幣初始版本VC6.0編譯


1 源碼下載

github上初始版本是bitcoin-0.1.5,可以從https://github.com/bitcoin/bitcoin下載,但是從網上可以找到更老版本bitcoin-0.1.0,例如可以從如下地址下載:

https://github.com/Dan-McG/bitcoin-0.1.0

網上可以搜到一封關於這個版本的說明郵件,內容如下

Announcing the first release of Bitcoin, a new electronic cash

system that uses a peer-to-peer network to prevent double-spending.

It's completely decentralized with no server or central authority.

See bitcoin.org for screenshots.

Download link:

http://downloads.sourceforge.net/bitcoin/bitcoin-0.1.0.rar

Windows only for now. Open source C++ code is included.

- Unpack the files into a directory

- Run BITCOIN.EXE

- It automatically connects to other nodes

If you can keep a node running that accepts incoming connections,

you'll really be helping the network a lot. Port 8333 on your

firewall needs to be open to receive incoming connections.

The software is still alpha and experimental. There's no guarantee

the system's state won't have to be restarted at some point if it

becomes necessary, although I've done everything I can to build in

extensibility and versioning.

You can get coins by getting someone to send you some, or turn on

Options->Generate Coins to run a node and generate blocks. I made

the proof-of-work difficulty ridiculously easy to start with, so

for a little while in the beginning a typical PC will be able to

generate coins in just a few hours. It'll get a lot harder when

competition makes the automatic adjustment drive up the difficulty.

Generated coins must wait 120 blocks to mature before they can be

spent.

There are two ways to send money. If the recipient is online, you

can enter their IP address and it will connect, get a new public

key and send the transaction with comments. If the recipient is

not online, it is possible to send to their Bitcoin address, which

is a hash of their public key that they give you. They'll receive

the transaction the next time they connect and get the block it's

in. This method has the disadvantage that no comment information

is sent, and a bit of privacy may be lost if the address is used

multiple times, but it is a useful alternative if both users can't

be online at the same time or the recipient can't receive incoming

connections.

Total circulation will be 21,000,000 coins. It'll be distributed

to network nodes when they make blocks, with the amount cut in half

every 4 years.

first 4 years: 10,500,000 coins

next 4 years: 5,250,000 coins

next 4 years: 2,625,000 coins

next 4 years: 1,312,500 coins

etc...

When that runs out, the system can support transaction fees if

needed. It's based on open market competition, and there will

probably always be nodes willing to process transactions for free.

Satoshi Nakamoto

該版本是用VC6.0進行編譯的,結合源碼中的說明文檔可知,完成編譯還需如下依賴庫

wxWidgets http://www.wxwidgets.org/downloads/

OpenSSL http://www.openssl.org/source/

Berkeley DB http://www.oracle.com/technology/software/products/berkeley-db/index.html

Boost http://www.boost.org/users/download/

2 編譯依賴庫

2.1 編譯wxWidgets

初始版本中界面庫用的是wxWidgets,這里選用版本wxWidgets-2.8.10,編譯時盡量使用和該文中相同的版本,否則可能會有問題,該庫編譯過程很簡單,直接用VC6.0打開圖中靜態工程wx.dsw,並編譯相應的Debug和Release版本即可,如圖

2.2 編譯OpenSSL

OpenSSL 是一個安全套接字層密碼庫,囊括主要的加密算法,比特幣源碼直接使用了該庫中的相關加密算法。這里選用的是源碼說明文件readme.txt中的版本openssl-0.9.8h.tar.gz,編譯OpenSSL需要安裝nasm和ActivePerl可參考如下網址

https://www.cnblogs.com/passedbylove/p/5977777.html
https://blog.csdn.net/liangyuannao/article/details/7788004

打開命令行並進入到源碼目錄,執行如下命令即可完成編譯

perl Configure VC-WIN32
ms\do_ms.bat
nmake -f ms\ntdll.mak

2.3 編譯Berkeley DB

Berkeley DB是一個開源的文件數據庫,比特幣借助該庫實現文件存取,這里選用的版本是db-4.7.25.tar.gz,直接用VC6.0打開圖中工程,並編譯其中Win32 Debug x86和Win32 Release x86版本

2.4 編譯Boost

這里選用版本boost_1_34_1.tar.gz,更新的版本用VC6.0編譯會有很多編譯錯誤。
(1)生成bjam.exe,打開cmd命令行,進入到boost_1_34_1\tools\jam\src目錄下,運行build.bat,build.bat會運行VCVARS32.BAT,設置環境變量,並編譯生成bjam,如圖

如果系統安裝多個VS版本,可以通過注釋其他版本來選擇VC6.0版本生成bjam.exe

最終會在目錄下生成一個名為bin.ntx86的文件夾里面包含一個bjam.exe可執行文件,將其拷貝到boost_1_34_1目錄下。

(2)有了bjam之后,運行 bjam --toolset=msvc-6.0進行編譯,bjam --toolset=msvc-6.0 install 生成相應的頭文件(include)和 庫文件(lib),默認生成在C:\boost下面。

3 新建VC工程並編譯

3.1 新建工程

新建Win32應用工程bitcoin

3.2 添加源碼文件

 將源碼中的頭文件源文件及資源文件添加到新建的工程中

3.3 修改編譯選項

將第2節編譯好的庫文件及相關頭文件拷貝到工程目錄下(如果不拷貝到工程目錄,則添加頭文件目錄時請填寫相應的文件路徑),添加相應庫頭文件路徑到附加頭文件目錄,添加宏定義D__WXMSW__,__WXDEBUG__到預定義中;添加相應的庫文件目錄到附加文件目錄,添加相應的依賴庫文件,libeay32.lib libdb47sd.lib wxmsw28d_richtext.lib wxmsw28d_html.lib wxmsw28d_core.lib wxbase28d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib,改Code Generation中Use run-time library為Debug Multithreaded DLL,在編譯選項中添加/Zm300,否則編譯時會有“compiler limit : internal heap limit reached; use /Zm to specify a higher limit”錯誤提示,在Resources設置下添加附件包含路徑include,主要編譯設置如下圖

 Release版本的編譯需要類似的設置,這里不在進行重復說明,已在CSDN上上傳了編譯好的版本,有需要的可自行下載https://download.csdn.net/download/weiwei22844/10642479


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM