您正在查看: Surou 发布的文章

Installing Boost library... 下载不下来

由于各种原因和姿势boost下载不下来,手动传一个包,改下脚本地址,从指定的地方下载把。。
此时上传的是:boost_1_67_0.tar.bz2
当前文件上传的地址:http://dl.aceui.cn/uploads/tools/boost_$BOOST_VERSION.tar.bz2
编辑脚本:vi eosio_build_ubuntu.sh

BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\  -f3 )
if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then
        printf "Installing Boost library...\\n"
        curl -LO http://dl.aceui.cn/uploads/tools/boost_$BOOST_VERSION.tar.bz2 \
        && tar -xjf boost_$BOOST_VERSION.tar.bz2 \

build fails - Unable to find the requested Boost libraries.

cd  ~/opt
rm -rf boost/
./eos_source_dir/eosio_build.sh

One workaround is to cd into ~/opt and remove the boost library there.
Re-compile using ./eosio_build.sh and it should work.

参考:
https://github.com/EOSIO/eos/issues/3464

EOS合约内解析json

示例代码

//demo.hpp
#pragma once

#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include "json.hpp"
#include <string>

using json = nlohmann::json;
using eosio::contract;
using eosio::multi_index;
using eosio::print;

class[[eosio::contract]] demo : public contract
{
  public:
    using contract::contract;

    [[eosio::action]] void demoaction();
};
//demo.cpp
#include "demo.hpp"
using json = nlohmann::json;

// ACTION
void demo::demoaction()
{
    json demoInfo = R"(
    {
        "demoInfo": {
            "hello": "world"
        }
    }
    )"_json;
    std::string demoInfoString = demoInfo.dump();
    json demoInfoJson = json::parse(demoInfoString);
    print("It worked\n");
}

EOSIO_DISPATCH(demo, (demoaction))

json.hpp从https://github.com/nlohmann/json/releases 下载并将其放在同一目录中demo.hpp。

参考

https://github.com/EOSIO/eosio.cdt/issues/110

Error compiling LLVM and clang with EXPERIMENTAL WASM support

解决方案:

cd /tmp/llvm-compiler/llvm/build
make -j4 install
rm -rf /tmp/llvm-compiler

最终一般会安装在$HOME/opt/wasm
参考地址:https://github.com/EOSIO/eos/issues/1694

更换Ubuntu镜像,解决EOS编译时,相关依赖下载失败

最近更新EOS代码,由于历史上最伟大的发明qiang,导致编译过程中某些依赖下载失败,so..

ubuntu 18.04

Ubuntu 的软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件做个备份,将该文件替换为下面内容,即可使用 TUNA 的软件源镜像。

#备份
sudo cp -i /etc/apt/sources.list /etc/apt/sources.list.bak
#编辑
sudo vi /etc/apt/sources.list

将文件内容修改为如下

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

保存后,重新sudo apt-get update后,重新编译

数据来源

https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
http://mirrors.ustc.edu.cn/help/ubuntu.html