由于比特币的开发基本都是在linux下的,所以我也是在linux下搭建的环境。(ubuntu 16.04)
首先是比特币源码的编译
Preparation
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libqt5gui5 libqt5core5 libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
sudo apt-get install libqrencode-dev
sudo apt-get install libminiupnpc-dev
Download bitcoin source code
cd ~
git clone https://github.com/bitcoin/bitcoin.git
###Download and compile Berkley DB 4.8
cd ~
mkdir bitcoin/db4/
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
tar -xzvf db-4.8.30.NC.tar.gz
cd db-4.8.30.NC/build_unix/
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=/home/theusername/bitcoin/db4/
make install
Compile Bitcoin with Berkley DB 4.8
cd ~/bitcoin/
./autogen.sh
./configure LDFLAGS="-L/home/theusername/bitcoin/db4/lib/" CPPFLAGS="-I/home/theusername/bitcoin/db4/include/"
make -s -j5
Run Bitcoin Daemon/QT/Client
./src/bitcoind
./src/qt/bitcoin-qt
./src/bitcoin-cli
参考链接:https://gist.github.com/kostaz/19729e6d53adc5d1606c
环境的搭建
用NetBeans IDE
首先按照之前的操作将比特币源码编译完之后,才可以进行以下的操作:
- 下载NetBeans IDE
Now you’re ready to install an IDE. You can download the C/C++ bundle of NetBeans from https://netbeans.org/downloads/ - chmod 755 netbeans-8.2-cpp-linux.sh//截至到2016/10/20的最新版本
- ./netbeans-8.2-cpp-linux.sh
- 完成安装之后:
Select File => New Project => C/C++ Project with Existing Sources => Next
then select your Bitcoin Core checkout directory. NetBeans will build the project and then run a code analysis. Now you’re ready to start developing!
用vim查看:
首先配置自己的vim
(我用的这个https://github.com/tao12345666333/vim/blob/master/README-zh.md)
- 然后添加tab:
- (前提需要安装ctags)在bitcoin/src/目录下使用 ctags –R 命令,就会在bitcoin/src /目录下生成tags文件。
- 然后在~/.vimrc文件中添加配置信息:set tags=/home/usrName/bitcoin/src/tags(这里其实就是生成的tags的位置)
- 用配置好的vim就可以轻松的查看代码了。