windows环境 需要安装 MingGW,

可以从我这里下载: https://download.csdn.net/download/fareast_mzh/16291876

下载boost源码包:

链接: https://pan.baidu.com/s/1ke2teh1_B1GXV5MnRqSMGw 提取码: tdyw 复制这段内容后打开百度网盘手机App,操作更方便哦

wget ​​https://dl.bintray.com/boostorg/release/1.70.0/source/​​​​boost_1_70_0.zip​

unzip boost_1_70.0.zip -d ./boost

cd ./boost

./bootstrap.sh --prefix=/usr/local/

./bootstrap.sh --prefix=/usr/local/
Building Boost.Build engine with toolset darwin... tools/build/src/engine/bin.macosxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7
Unicode/ICU support for Boost.Regex?... not found.
Backing up existing Boost.Build configuration in project-config.jam.1
Generating Boost.Build configuration in project-config.jam for darwin...

Bootstrapping is done. To build, run:

./b2

To generate header files, run:

./b2 headers

To adjust configuration, edit 'project-config.jam'.
Further information:

- Command line help:
./b2 --help

- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html

- Boost.Build documentation:
http://www.boost.org/build/

./bootstrap.sh --prefix=/usr/local/
Building Boost.Build engine with toolset darwin... tools/build/src/engine/bin.macosxx86_64/b2
Detecting Python version... 2.7
Detecting Python root... /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7
Unicode/ICU support for Boost.Regex?... not found.
Backing up existing Boost.Build configuration in project-config.jam.1
Generating Boost.Build configuration in project-config.jam for darwin...

Bootstrapping is done. To build, run:

./b2

To generate header files, run:

./b2 headers

To adjust configuration, edit 'project-config.jam'.
Further information:

- Command line help:
./b2 --help

- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html

- Boost.Build documentation:
http://www.boost.org/build/

sudo ./bjam install

 

---------------------------------------------------------------------------------------------------------------

boost开发只需要头文件引入

把boost/boost 目录copy到 /usr/local/include

* A.cpp

#include <iostream>
#include <boost/smart_ptr.hpp>

using namespace boost;

class A {
public:
A(int val) {
m_a = val;
std::cout << "A constructor" << std::endl;
}

int GetA() {return m_a;}

virtual ~A() {
std::cout << "A destruct" << std::endl;
}

private:
int m_a;
};

class B {
public:
B(int val) {
m_val = val;
std::cout << "B construct" << std::endl;
}
~B() {std::cout << "B destruct" << std::endl;}
int getVal() {return m_val;}

private:
int m_val;
};

int main(int argc, char *argv[]) {

boost::scoped_ptr<int> int_ptr(new int);
*int_ptr = 10;
std::cout << ++*int_ptr << std::endl;

boost::scoped_ptr<A> sc_ptr(new A(1));
std::cout << sc_ptr->GetA() << std::endl;

// sc_ptr.reset();
B *b = new B(2);
std::cout << b->getVal() << std::endl;

return 0;
}
#include <iostream>
#include <boost/smart_ptr.hpp>

using namespace boost;

class A {
public:
A(int val) {
m_a = val;
std::cout << "A constructor" << std::endl;
}

int GetA() {return m_a;}

virtual ~A() {
std::cout << "A destruct" << std::endl;
}

private:
int m_a;
};

class B {
public:
B(int val) {
m_val = val;
std::cout << "B construct" << std::endl;
}
~B() {std::cout << "B destruct" << std::endl;}
int getVal() {return m_val;}

private:
int m_val;
};

int main(int argc, char *argv[]) {

boost::scoped_ptr<int> int_ptr(new int);
*int_ptr = 10;
std::cout << ++*int_ptr << std::endl;

boost::scoped_ptr<A> sc_ptr(new A(1));
std::cout << sc_ptr->GetA() << std::endl;

// sc_ptr.reset();
B *b = new B(2);
std::cout << b->getVal() << std::endl;

return 0;
}

ubuntu@et-dev-mingzhanghui:~/code/clang$ g++ AB.cpp -Wall && ./a.out
11
A constructor
1
B construct
2
A destruct
对比普通指针没有调用destruct方法, 智能指针调用了。

 

如果出现错误

A.cpp:2:31: fatal error: boost/smart_ptr.hpp: No such file or directory
compilation terminated.
说明没有找到 boost头文件

参照文章:

C++ Boost 智能指针 ​​https://mp.weixin.qq.com/s/cSdgEBF88LjTjOtnN8T6YA​

C++ Boost 零基础学习笔记 https://blog.csdn.net/yao_hou/column/info/35572

---------------------------------------------------------------------------------------------------------------

Buy and sell cryptocurrency   ​​https://www.coinbase.com/​

BlockChain                             ​​https://www.blockchain.com/​

remme                                    ​​https://remme.io/​

hyperledger                            ​​https://hyperledger-fabric.readthedocs.io/en/release-1.4/​

 


本文列出个人在编译以及启动运行中遇到的问题。

1 执行autogen.sh libtool没有安装
Makefile.am:10: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:10:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:10:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:10:   If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:10:   its definition is in aclocal's search path.
解决方法:yum install libtool -y 

2 执行autogen.sh aclocal找不到
解决方法:问题原因是机器没有安装autotool工具系列,需要安装automake和autoconf

yum install automake -y
yum install autoconf 
3 configure: error: openssl not found
执行bitcoind目录下的configure过程中出现openssl库没有找到的情况,执行命令:openssl version -a 查看系统如果安装(大多数系统都会安装),则需要安装openssl-devel,执行如下命令

yum install openssl-devel
4 checking for libevent... no configure: error: libevent not found
原因是系统中没有安装libevent库,解决办法为手动安装。打开http://libevent.org/选择libevent的版本,本人选择libevent-2.0.22-stable.tar.gz, 下载代码到系统中。执行如下命令 :

./configure --prefix=/user/local/
make 
make install
安装成功后,运行bitcoin目录下的configure如果仍然出现上述问题是因为没有安装libeven-devel,执行命令

yum install libevent-devel
5 configure: error: libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)
问题的原因是没有安装BekerlyDB,解决方法如下:

wget http://download.oracle.com/berkeley-db/db-4.8.30.zip
unzip db-4.8.30.zip
cd db-4.8.30
cd build_unix/
../dist/configure --prefix=/usr/local --enable-cxx
make
make install
注意如果运行过程中出现找不到libdb.xxx.so的时候原因是一样的,都是由于没有安装BerkelyDB的原因。

configure: error: Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)

如果遇到上述错误,解决的方法一样,需要安装BerkeleyDB 同时在configure后面添加

--with-incompatible-bdb
 

6 configure: error: No working boost sleep implementation found.
核心问题,也是比较常见的问题,原因是系统中没有安装boot库,解决方法如下:

下载 boost (http://www.boost.org/users/history/version_1_66_0.html)
cd boost_1_66_0/
./bootstrap.sh --prefix=/usr/local/
./bjam install
注意bootstrap中的prefix参数很重要,这个直接决定后面运行的时候如果出现libboost.xxx.so找不到的解决方法

7 tmp/ccuyuMIK.s:93510: Error: no such instruction: `vextracti128 $0x1,%ymm0,%xmm1'
问题是AS的版本过低导致,可以通过更新AS的版本来解决该问题

wget https://ftp.gnu.org/gnu/binutils/binutils-2.31.tar.gz
tar zxvf binutils-2.31.tar.gz
cd binutils-2.31
./configure 
make 
make install
8 如果有需要编译boost,在编译的过程中出现找不到pyconfig.h的错误
机器上没有安装对应的pythond-devel,解决方法如下

yum install python-devel.x86_64
以上的问题是编译过程遇到的问题,下面主要是运行过程中遇到的问题

1 启动bitcoind 出现找不到动态链接库的问题
error while loading shared libraries: libdb_cxx-4.8.so: cannot open shared object file: No such file or directory

error while loading shared libraries: libboost.xxxx.so: cannot open shared object file: No such file or directory

主要原因是动态链库找不到,可以通过修改libc.conf来实现

vim /etc/ld.so.conf.d/libc.conf
添加刚才安装的boost等库的路径例如
/usr/local/lib
/usr/lib
保存libc.conf
执行ldconfig

--------------------- 
版权声明:本文为CSDN博主「SunnyPirateCoder」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/SunnyWed/article/details/83819467

 

下一篇 CLion使用: https://blog.csdn.net/fareast_mzh/article/details/100049813