超级账本子项目 iroha 私链部署

安装

  ==尽量采用高版本的Ubuntu内核版本或GCC版本==

依赖包

  • 下载 iroha

    git clone -b https://github.com/hyperledger/iroha
  • 环境配置

    sudo apt-get install build-essential python-software-properties automake libtool \
    libssl-dev zlib1g-dev  libc6-dbg golang \
    ca-certificates lcov  cmake iputils-ping ccache gcovr vera++\
    cppcheck doxygen graphviz graphviz-dev libgtest-dev libgflags-dev
    
    • cmake

      
      # 下载 cmake 安装脚本
      
      wget https://cmake.org/files/v3.10/cmake-3.10.3-Linux-x86_64.sh
      
      
      # 安装
      
      sudo sh cmake-3.10.3-Linux-x86_64.sh
      
      
      # 根据提示选择安装路径
      
      
      # 配置环境变量 修改 .bashrc
      
      vim ~/.bashrc
      export PATH="/cmake/install/path/bin:$PATH"
      
      # 加载环境变量
      
      source ~/.bashrc
    • boost

      ==注: Boost v1.65运行正常, v1.66运行 coredump==

      
      # download boost
      
      wget https://dl.bintray.com/boostorg/release/1.65.0/source/boost_1_65_0.tar.gz
      
      # 编译
      
      ./bootstrap.sh --with-libraries=system,filesystem 
      ./b2
    • libcares

      
      # 编译安装
      
      wget https://c-ares.haxx.se/download/c-ares-1.14.0.tar.gz
      ./configure
      make && sudo make install
    • protobuf

      
      # 编译添加fPIC 解决静态库依赖错误
      
      ./configure CXXFLAGS=-fPIC
      make && sudo make install

    ==注: 编译Google全家桶时,修改gcc 版本对应的cplusplus c++config.h 文件中的宏 _GLIBCXX_USE_CXX11_ABI 为0 ; 例如: /usr/include/x86_64-linux-gnu/c++/6/bits/c++config.h
    ; 否则后续编译可能会出现 动态库引用 undefined==

    • grpc
      
      # 安装依赖包
      
      sudo apt-get install libgoogle-perftools-dev build-essential\
      autoconf libtool pkg-config
      
      
      # 下载最新代码包
      
      git clone https://github.com/grpc/grpc.git
      git submodule update --init
      
      make && sudo make instal

    若GCC版本过低可能会遇见如下问题:

    
    # grpc_cpp_plugin 运行 coredump
    
    terminate called after throwing an instance of 'std::system_error

    解决方案, 修改Makefile, 添加 -Wl,--no-as-needed 编译参数, 具体参考Stackoverflow: terminate called after throwing an instance of ‘std::system_error’

    379 ifeq ($(SYSTEM),Linux)
    380 LIBS = dl rt m pthread
    381 LDFLAGS += -pthread -Wl,--no-as-needed
    382 endif
    383 
    384 ifeq ($(SYSTEM),MINGW32)
    385 LIBS = m pthread ws2_32
    386 LDFLAGS += -pthread
    387 endif

编译

  • 编译

    
    # 运行 cmake 生成 build 文件; binaries package cmake 添加参数 -DPACKAGE_ZIP=ON
    
    borey-zhu@AWS-TEST-DT:~/blockchain/iroha$ cmake -H. -DCMAKE_BUILD_TYPE=Release -Bbuild
    -- The C compiler identification is GNU 6.3.0 -- The CXX compiler identification is GNU 6.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- -DCMAKE_BUILD_TYPE=Release -- -DTESTING=ON -- -DBENCHMARKING=OFF -- -DFUZZING=OFF -- -DCOVERAGE=OFF -- -DPACKAGE_ZIP=OFF -- -DPACKAGE_TGZ=OFF -- -DPACKAGE_RPM=OFF -- -DPACKAGE_DEB=OFF -- -DENABLE_LIBS_PACKAGING=ON -- -DSWIG_PYTHON=OFF -- -DSWIG_JAVA=OFF -- -DSUPPORT_PYTHON2=OFF -- -DSWIG_CSHARP=OFF -- -DSHARED_MODEL_DISABLE_COMPATIBILITY=OFF 
    # 缺失包 https://github.com/google/googletest
    
    -- Could NOT find gtest (missing: gtest_LIBRARY gtest_MAIN_LIBRARY gmock_INCLUDE_DIR gmock_LIBRARY gmock_MAIN_LIBRARY) 
    # 缺失包 https://github.com/gabime/spdlog.git
    
    -- Could NOT find spdlog (missing: spdlog_INCLUDE_DIR) -- Found protobuf: /usr/local/include -- Found grpc: /usr/local/lib/libgrpc.so 
    # 缺失包 https://github.com/miloyip/rapidjson.git
    
    -- Could NOT find rapidjson (missing: rapidjson_INCLUDE_DIR) 
    # 缺失包 https://git.postgresql.org/git/postgresql.git
    
    -- Could NOT find pq (missing: pq_INCLUDE_DIR postgres_INCLUDE_DIR pq_LIBRARY pg_config_EXECUTABLE) 
    # 缺失包 https://github.com/jtv/libpqxx.git
    
    -- Could NOT find pqxx (missing: pqxx_INCLUDE_DIR pqxx_LIBRARY) 
    # 缺失包 https://github.com/Reactive-Extensions/rxcpp.git
    
    -- Could NOT find rxcpp (missing: rxcpp_INCLUDE_DIR) 
    # 缺失包 https://github.com/01org/tbb.git
    
    -- Could NOT find tbb (missing: tbb_INCLUDE_DIR tbb_LIBRARY) -- Boost version: 1.65.0 -- Found the following Boost libraries: -- filesystem -- system 
    # 缺失包 https://github.com/hyperledger/iroha-ed25519
    
    -- Could NOT find ed25519 (missing: ed25519_INCLUDE_DIR ed25519_LIBRARY) -- Configuring done -- Generating done -- Build files have been written to: /home/borey-zhu/blockchain/iroha/build 
    
    # 对依赖进行下载编译
    
    cd build && make -j4
    
    #或进行对上述依赖包进行独立安装
    
    cmake -H. -DBOOST_ROOT=/home/prod/softwares/boost_1_65_0/ \
    -Dpostgres_INCLUDE_DIR=/usr/local/pgsql/include/ \ -Dpq_INCLUDE_DIR=/usr/local/pgsql/include/libpq/ \ -Dpq_LIBRARY=/usr/local/pgsql/lib/libpq.so \ -Dpg_config_EXECUTABLE=/usr/local/pgsql/bin/ \ -Dtbb_INCLUDE_DIR=/home/prod/softwares/tbb/include/ \ -Dtbb_LIBRARY=/usr/local/lib/libtbb.so \ -Bbuild

Postgresql 配置

prod@AWS-TEST-DT:~$ sudo groupadd postgres
prod@AWS-TEST-DT:~$ sudo useradd postgres -g postgres

$ mkdir pgdata
$ mkdir pglog
prod@AWS-TEST-DT:/extdisk1/postgres$ sudo su - postgres
No directory, logging in with HOME=/
$ cd /extdisk1/
$ mkdir -p postgres/pgdata
$ mkdir -p postgres/pglog
$ /usr/local/pgsql/bin/initdb -D /extdisk1/postgres/pgdata/ -E UTF8 --locale=C
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /extdisk1/postgres/pgdata ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/pgsql/bin/pg_ctl -D /extdisk1/postgres/pgdata/ -l logfile start

# start server
$ /usr/local/pgsql/bin/pg_ctl -D /extdisk1/postgres/pgdata/ -l /extdisk1/postgres/pglog/pg.log  start
waiting for server to start.... done
server started

# stop server
$ /usr/local/pgsql/bin/pg_ctl -D /extdisk1/postgres/pgdata/ -l /extdisk1/postgres/pglog/pg.log  stop
waiting for server to shut down.... done
server stopped

# 修改密码
$ /usr/local/pgsql/bin/psql -U postgres
psql (11devel)
Type "help" for help.

postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
postgres=# alter user postgres with password '123456';
ALTER ROLE
postgres=# \q

# 修改文件 pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     md5
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

部署

# 配置节点
echo 'localhost:10001' > peers.list

# 生成创世块 和 对应的密钥对
iroha-cli --genesis_block --peers_address peers.list

# 生成如下列文件
borey-zhu@AWS-TEST-DT:~/ext_data/iroha/conf$ ls -l
total 36
-rw-rw-r-- 1 borey-zhu borey-zhu   64 Mar 27 14:26 [email protected]
-rw-rw-r-- 1 borey-zhu borey-zhu   64 Mar 27 14:26 [email protected]
-rw-rw-r-- 1 borey-zhu borey-zhu 4027 Mar 27 14:26 genesis.block
-rw-rw-r-- 1 borey-zhu borey-zhu   64 Mar 27 14:26 node0.priv
-rw-rw-r-- 1 borey-zhu borey-zhu   64 Mar 27 14:26 node0.pub
-rw-rw-r-- 1 borey-zhu borey-zhu   16 Mar 27 14:19 peers.list
-rw-rw-r-- 1 borey-zhu borey-zhu   64 Mar 27 14:26 [email protected]
-rw-rw-r-- 1 borey-zhu borey-zhu   64 Mar 27 14:26 [email protected]

# 创建配置文件
# 每个节点都对应独的 redis & postgresql
borey-zhu@AWS-TEST-DT:~/ext_data/iroha/conf$ cat config.json 
{
  "block_store_path" : "/home/borey-zhu/ext_data/iroha/data/block_store/",
  "torii_port" : 50051,
  "internal_port" : 10001,
  "pg_opt" : "host=localhost port=5432 user=postgres password=312312",
  "redis_host" : "localhost",
  "redis_port" : 3807,
  "max_proposal_size" : 10,
  "proposal_delay" : 5000,
  "vote_delay" : 5000,
  "load_delay" : 5000
}

# 运行iroha
nohup irohad --config conf/config.json  --genesis_block conf/genesis.block --keypair_name conf/node0 &

# 日志
borey-zhu@AWS-TEST-DT:~/ext_data/iroha$ cat nohup.out 
[14:50:42][th: 25603][info] [MAIN] << start [14:50:42][th: 25603][info] [MAIN] << config initialized [14:50:42][th: 25603][info] [IROHAD] << created [14:50:42][th: 25603][info] [StorageImpl:initConnection] << Start storage creation [14:50:42][th: 25603][info] [StorageImpl:initConnection] << block store created [14:50:42][th: 25603][info] [StorageImpl:initConnection] << connection to Redis completed [14:50:42][th: 25603][info] [StorageImpl:initConnection] << connection to PostgreSQL completed [14:50:42][th: 25603][info] [StorageImpl:initConnection] << transaction to PostgreSQL initialized [14:50:42][th: 25603][info] [IROHAD] << [Init] => storage
[14:50:42][th: 25603][info] [StorageImpl] << Drop ledger [14:50:42][th: 25603][info] [StorageImpl] << drop dp [14:50:42][th: 25603][info] [StorageImpl] << drop redis [14:50:42][th: 25603][info] [StorageImpl] << drop block store [14:50:42][th: 25603][info] [MAIN] << Block is parsed [14:50:42][th: 25603][info] [MAIN] << Genesis block inserted, number of transactions: 1 [14:50:42][th: 25603][info] [IROHAD] << [Init] => converters
[14:50:42][th: 25603][info] [IROHAD] << [Init] => peer query
[14:50:42][th: 25603][info] [IROHAD] << [Init] => crypto provider
[14:50:42][th: 25603][info] [IROHAD] << [Init] => validators
[14:50:42][th: 25603][info] [OrderingGate] << Subscribe [14:50:42][th: 25603][info] [IROHAD] << [Init] => init ordering gate - [true]
[14:50:42][th: 25603][info] [IROHAD] << [Init] => init simulator
[14:50:42][th: 25603][info] [IROHAD] << [Init] => block loader
[14:50:42][th: 25603][info] [IROHAD] << [Init] => consensus gate
[14:50:42][th: 25603][info] [IROHAD] << [Init] => synchronizer
[14:50:42][th: 25603][info] [IROHAD] << [Init] => pcs
[14:50:42][th: 25603][info] [IROHAD] << [Init] => command service
[14:50:42][th: 25603][info] [IROHAD] << [Init] => query service
[14:50:42][th: 25603][info] [MAIN] << Running iroha [14:50:42][th: 25603][info] [IROHAD] << ===> iroha initialized

命令行交互模式

# 进入交互模式
iroha-cli --interactive  -name admin@test --key_path conf/

# 选择 2
Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 2 

# 查看当前 Role
Choose query: 
1. Get all permissions related to role (get_role_perm)
2. Get Transactions by transactions' hashes (get_tx)
3. Get information about asset (get_ast_info)
4. Get Account's Transactions (get_acc_tx)
5. Get all current roles in the system (get_roles)
6. Get Account's Signatories (get_acc_sign)
7. Get Account's Assets (get_acc_ast)
8. Get Account Information (get_acc)
0. Back (b)
> : 5
Query is formed. Choose what to do:
1. Send to Iroha peer (send)
2. Save as json file (save)
0. Back (b)
> : 1
Peer address: 127.0.0.1
Peer port: 50051
[17:24:18][th: 26754][info] [QueryResponseHandler] << admin [17:24:18][th: 26754][info] [QueryResponseHandler] << user [17:24:18][th: 26754][info] [QueryResponseHandler] << money_creator --------------------

创建Domain

Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 1
Forming a new transactions, choose command to add: 
1. Detach role from account (detach)
2. Add new role to account (apnd_role)
3. Create new role (crt_role)
4. Set account key/value detail (set_acc_kv)
5. Transfer Assets (tran_ast)
6. Grant permission over your account (grant_perm)
7. Subtract Assets Quantity from Account (sub_ast_qty)
8. Set Account Quorum (set_qrm)
9. Remove Signatory (rem_sign)
10. Create Domain (crt_dmn)
11. Revoke permission from account (revoke_perm)
12. Create Account (crt_acc)
13. Add Signatory to Account (add_sign)
14. Create Asset (crt_ast)
15. Add Peer to Iroha Network (add_peer)
16. Add Asset Quantity (add_ast_qty)
0. Back (b)
> : 10
# 创建 domain id borey
Domain Id: borey
Default Role name: money_creator
Command is formed. Choose what to do:
1. Add one more command to the transaction (add)
2. Send to Iroha peer (send)
3. Go back and start a new transaction (b)
4. Save as json file (save)
> : 2
Peer address: 127.0.0.1
Peer port: 50051
[17:25:03][th: 26754][info] [TransactionResponseHandler] << Transaction successfully sent
Congratulation, your transaction was accepted for processing.
Its hash is 6cc2707fb997782c6550a7a5f9cf03122f2f61f25693bc510f8b0e4d726fd6d4
--------------------

# 查询交易信息
Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 3
Choose action: 
1. Get status of transaction (get_tx_info)
0. Back (b)
> : 1
Requested tx hash: 6cc2707fb997782c6550a7a5f9cf03122f2f61f25693bc510f8b0e4d726fd6d4
Tx hash is saved. Choose what to do:
1. Send to Iroha peer (send)
2. Save as json file (save)
0. Back (b)
> : 1
Peer address: 127.0.0.1
Peer port: 50051
# 成功
Transaction was successfully committed.
--------------------
Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)

创建资产

Forming a new transaction. Choose command to add: 
1. Detach role from account (detach)
2. Add new role to account (apnd_role)
3. Create new role (crt_role) 4. Set account key/value detail (set_acc_kv) 5. Transfer Assets (tran_ast) 6. Grant permission over your account (grant_perm) 7. Subtract Assets Quantity from Account (sub_ast_qty) 8. Set Account Quorum (set_qrm) 9. Remove Signatory (rem_sign) 10. Create Domain (crt_dmn) 11. Revoke permission from account (revoke_perm) 12. Create Account (crt_acc) 13. Add Signatory to Account (add_sign) 14. Create Asset (crt_ast) 15. Add Peer to Iroha Network (add_peer) 16. Add Asset Quantity (add_ast_qty) 0. Back (b) > : 14 # 发现wcoin资产 Asset name: wcoin # 选择domain id Domain Id: borey # 精度为 2 Asset precision: 2 Command is formed. Choose what to do: 1. Add one more command to the transaction (add) 2. Send to Iroha peer (send) 3. Go back and start a new transaction (b) 4. Save as json file (save) > : 2 Peer address: 127.0.0.1 Peer port: 50051 [17:33:17][th: 26754][info] [TransactionResponseHandler] << Transaction successfully sent Congratulation, your transaction was accepted for processing. Its hash is 09726a5781af2c703a903bf451f11442e57104f4bbb1ad691b6bf15de771e2e8 -------------------- Choose what to do: 1. New transaction (tx) 2. New query (qry) 3. New transaction status request (st) > : 3 Choose action: 1. Get status of transaction (get_tx_info) 0. Back (b) > : 1 Requested tx hash: 09726a5781af2c703a903bf451f11442e57104f4bbb1ad691b6bf15de771e2e8 Tx hash is saved. Choose what to do: 1. Send to Iroha peer (send) 2. Save as json file (save) 0. Back (b) > : 127.0.0.1 Command not found: 127.0.0.1 Parser for command not found > : 1 Peer address: 127.0.0.1 Peer port: 50051 # 创建资产成功 Transaction was successfully committed. -------------------- Choose what to do: 1. New transaction (tx) 2. New query (qry) 3. New transaction status request (st)

给账户添加资产数量

Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 1
Forming a new transactions, choose command to add: 
1. Detach role from account (detach)
2. Add new role to account (apnd_role)
3. Create new role (crt_role)
4. Set account key/value detail (set_acc_kv)
5. Transfer Assets (tran_ast)
6. Grant permission over your account (grant_perm)
7. Subtract Assets Quantity from Account (sub_ast_qty)
8. Set Account Quorum (set_qrm)
9. Remove Signatory (rem_sign)
10. Create Domain (crt_dmn)
11. Revoke permission from account (revoke_perm)
12. Create Account (crt_acc)
13. Add Signatory to Account (add_sign)
14. Create Asset (crt_ast)
15. Add Peer to Iroha Network (add_peer)
16. Add Asset Quantity (add_ast_qty)
0. Back (b)
> : 16
# 选择账户id
Account Id: admin@test
# 资产
Asset Id: wcoin#borey
Amount to add (integer part): 100000000
Amount to add (precision): 2
100000000 2
Command is formed. Choose what to do:
1. Add one more command to the transaction (add)
2. Send to Iroha peer (send)
3. Go back and start a new transaction (b)
4. Save as json file (save)
> : 2
Peer address: 127.0.0.1
Peer port: 50051
[17:39:56][th: 26754][info] [TransactionResponseHandler] << Transaction successfully sent
Congratulation, your transaction was accepted for processing.
Its hash is 92db22d62024ff9170f8044fc0c569cb08da7ac07d96a06fb28fab071cd920ed
--------------------
# 查询交易
Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 3
Choose action: 
1. Get status of transaction (get_tx_info)
0. Back (b)
> : 1
Requested tx hash: 92db22d62024ff9170f8044fc0c569cb08da7ac07d96a06fb28fab071cd920ed
Tx hash is saved. Choose what to do:
1. Send to Iroha peer (send)
2. Save as json file (save)
0. Back (b)
> : 1
Peer address: 127.0.0.1
Peer port: 50051
# 成功
Transaction was successfully committed.

查询资产

Choose what to do:
1. New transaction (tx)
2. New query (qry)
3. New transaction status request (st)
> : 2
Choose query: 
1. Get all permissions related to role (get_role_perm)
2. Get Transactions by transactions' hashes (get_tx)
3. Get information about asset (get_ast_info)
4. Get Account's Transactions (get_acc_tx)
5. Get all current roles in the system (get_roles)
6. Get Account's Signatories (get_acc_sign)
7. Get Account's Assets (get_acc_ast)
8. Get Account Information (get_acc)
0. Back (b)
> : 7
# 输入账户
Requested account Id: admin@test
# 输入资产
Requested asset Id: wcoin#borey
Query is formed. Choose what to do:
1. Send to Iroha peer (send)
2. Save as json file (save)
0. Back (b)
> : 1
Peer address: 127.0.0.1
Peer port: 50051
[17:43:04][th: 26754][info] [QueryResponseHandler] << [Account Assets] [17:43:04][th: 26754][info] [QueryResponseHandler] << -Account Id- admin@test [17:43:04][th: 26754][info] [QueryResponseHandler] << -Asset Id- wcoin#borey [17:43:04][th: 26754][info] [QueryResponseHandler] << -Balance- 1000000.00 -------------------- 

Python API 编译

gcc version 6.3.0 

sudo pip install grpcio-tools -i http://mirrors.aliyun.com/pypi/simple/ 

cd example/python

# 修改prepare.sh 文件 cmake -H$IROHA_HOME -DCMAKE_BUILD_TYPE=Release -Dprotobuf_LIBRARY=/usr/local/lib/libprotobuf.a -Bbuild -DSWIG_PYTHON=ON;
./pre
pare.sh

# 编译后Linux下的API的文件为 build/shared_model/bindings/ 目录下的:
iroha.py  _iroha.so

prod@ubuntu:~/blockchain/iroha/example/python/build$ ldd  shared_model/bindings/_iroha.so 
    linux-vdso.so.1 =>  (0x00007ffe1711f000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5a81b5a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5a81851000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5a8163a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5a81270000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f5a82ad7000)

常见问题

GCC 升级

  • 手动升级

    1. gcc6.3.0的源代码压缩包,下载地址:

    镜像站点:

    https://gcc.gnu.org/mirrors.htm
    
    ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/
    1. 四个压缩包:

    m4:http://www.gnu.org/software/m4/m4.html

    gmp:https://gmplib.org/

    mpfr:http://www.mpfr.org/

    mpc:http://www.multiprecision.org/

    依次安装编译上述依赖包

    1. 编译

      
      # gcc 配置
      
      ./configure --prefix=/usr/local/gcc-6.3 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --program-suffix=6.3.0
      
      
      # 在编译GCC的过程中可能出现“configure: error: cannot compute suffix of object files: cannot compile”的错误,解决方法是:
      
      
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
      
      make -j4 && sudo make install
    2. 指定GCC版本

      export CC=/usr/local/gcc-6.3/bin/gcc
      export CXX=/usr/local/gcc-6.3/bin/g++
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/:/usr/local/gcc-6.3/lib/:/usr/local/gcc-6.3/lib64/
  • 自动升级

    配置源进行安装 https://launchpad.net/ubuntu/+ppas?name_filter=gcc

gtest undefined reference 错误

  ed25519_test.cpp:(.text+0x4ab): undefined reference to `testing::internal::GetBoolAssertionFailureMessage[abi:cxx11](testing::AssertionResult const&, char const*, char const*, char const*)’

  修改文件
vim /usr/local/gcc-5.5/include/c++/5.5.0/x86_64-unknown-linux-gnu/bits/c++config.h
  #define _GLIBCXX_USE_CXX11_ABI 0

  If you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace or the tag [abi:cxx11] then it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to a third-party library that was compiled with an older version of GCC. If the third-party library cannot be rebuilt with the new ABI then you will need to recompile your code with the old ABI.

cmake cannot find lpthreads

ERROR: cmake cannot find lpthreads

解决方案:
修改 cmake/dependencies.cmake 文件注释掉 #find_package(Threads REQUIRED)

irohad coredump

1、修改CMakeList.txt 中 DEBUG 编译参数选项 SET(CMAKE_CXX_FLAGS_DEBUG "-g -ggdb -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -O0")

2、重新编译

# 默认 -DCMAKE_BUILD_TYPE=Debug
cmake -H. -Bbuild
cd build && make -j4

3、修改 ulimit -c 的值

prod@ubuntu:~/blockchain/iroha$ ulimit -c unlimited
prod@ubuntu:~/blockchain/iroha$ ulimit -c
unlimited

4、运行irohad 生成 coredump 文件


gdb irohad --config conf/config.json --genesis_block init/genesis.block --keypair_name init/node0 [corefile]
# 查看程序crash堆栈信息
bt 

你可能感兴趣的:(blockchain)