【发布时间】:2020-09-22 23:29:33
【问题描述】:
我正在尝试在 EOS 智能合约中包含 boost UUID 库。
#include <string>
#include <eosio/crypto.hpp>
#include <boost/uuid/uuid.hpp>
我按照此链接安装 boost 只是将版本更改为 1.73.0 : http://janisz.github.io/2013/11/27/install-boost-on-ubuntu/
我执行的命令列表是:
sudo apt-get update
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev
sudo apt-get -y install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev
cd /tmp
wget http://downloads.sourceforge.net/project/boost/boost/1.73.0/boost_1_73_0.tar.gz
tar -zxvf boost_1_73_0.tar.gz
cd boost_1_73_0
./bootstrap.sh --prefix=/usr/local
cpuCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
echo "Available CPU cores: "$cpuCores
sudo ./b2 --with=all -j $cpuCores install
之后:
./bootstrap.sh --prefix=/usr && ./b2 stage threading=multi link=shared
./b2 install threading=multi link=shared && ln -svf detail/sha1.hpp /usr/include/boost/uuid/sha1.hpp
./b2 命令打印
ln: 未能创建符号链接 '/usr/include/boost/uuid/sha1.hpp': 权限被拒绝
然后:
sudo apt update
sudo apt install libboost-all-dev
并尝试编译智能合约:
eosio-cpp documentid.cpp -o documentid.wasm
它的错误:
fatal error: 'boost/uuid/uuid.hpp' file not found
有人能告诉我我做错了什么吗?
【问题讨论】:
-
您需要使用 sudo 运行 b2。您使用
sudo ./b2 --with=all -j $cpuCores install执行此操作,但执行./b2 install threading=multi link=shared时未执行此操作您执行sudo ./b2 --with=all -j $cpuCores install时生成的错误是什么? -
嘿..我试过
sudo ./b2 install threading=multi link=shared && ln -svf detail/sha1.hpp /usr/include/boost/uuid/sha1.hpp。它给出了相同的结果ln: failed to create symbolic link '/usr/include/boost/uuid/sha1.hpp' Permission denied。sudo ./b2 --with=all -j $cpuCores install没有错误 -
所以
ln -svf命令也需要sudo。每当您想对用户不拥有的目录执行某些操作时,您都需要 sudo。如果sudo ./b2 --with=all -j $cpuCores install正常工作,我不明白你为什么要执行第二个 b2 命令。 -
知道了。现在我尝试了
sudo ln -svf detail/sha1.hpp /usr/include/boost/uuid/sha1.hpp。现在它运行成功。但是fatal error: 'boost/uuid/uuid.hpp' file not found是一样的。
标签: c++ boost ubuntu-18.04 smartcontracts eos