Ubuntu下编译EOS指南

in #eos7 years ago (edited)

eos.jpeg

原文链接:https://steemit.com/eoskorea/@clayop/eos-build-guide-on-ubunbu

本文编译环境为Ubuntu 16.04 LTS(腾讯云),按原文编译会遇到Could NOT find GMP (missing: GMP_LIBRARIES GMP_INCLUDE_DIR)的问题,新增依赖libgmp3-dev后编译成功,下文命令已包含此依赖 ,我并没有在其他平台和系统上进行过测试。遇到任何问题,欢迎留言。

准备工作

screen -S compile # Optional
sudo -i # 获取 root

安装依赖

DEBIAN_FRONTEND=noninteractive apt-get install -y sudo wget net-tools ca-certificates unzip
echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" >> /etc/apt/sources.list.d/llvm.list
wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y git-core automake autoconf libtool build-essential pkg-config libtool \
    mpi-default-dev libicu-dev python-dev python3-dev libbz2-dev zlib1g-dev libssl-dev  \
    clang-4.0 lldb-4.0 lld-4.0 libgmp3-dev
rm -rf /var/lib/apt/lists/*
update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-4.0/bin/clang 400
update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-4.0/bin/clang++ 400

安装 cmake 3.9

cd /tmp
wget https://cmake.org/files/v3.9/cmake-3.9.0-Linux-x86_64.sh
mkdir /opt/cmake && chmod +x /tmp/cmake-3.9.0-Linux-x86_64.sh
sh /tmp/cmake-3.9.0-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake

安装 boost 1.64

cd /tmp && wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar zxf boost_1_64_0.tar.gz
cd boost_1_64_0
./bootstrap.sh --with-toolset=clang
./b2 -a -j$(nproc) stage release -sHAVE_ICU=1 --sICU_PATH=/usr
./b2 install --prefix=/usr
rm -rf /tmp/boost_1_64_0*

安装 secp256k1-zkp from cryptonomex repo

cd /tmp
git clone https://github.com/cryptonomex/secp256k1-zkp.git
cd secp256k1-zkp
./autogen.sh
./configure
make
make install
ldconfig
rm -rf /tmp/secp256k1-zkp*

安装 WASM compiler

cd /tmp && mkdir wasm-compiler && cd wasm-compiler
git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
cd llvm/tools && git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
cd .. && mkdir build && cd build
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/opt/wasm -DLLVM_TARGETS_TO_BUILD= \-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../
make -j$(nproc) install
rm -rf /tmp/wasm-compiler

Exit root

exit

安装 EOS

cd ~/
git clone https://github.com/EOSIO/eos.git --recursive
cd eos && mkdir build && cd build
WASM_LLVM_CONFIG=/opt/wasm/bin/llvm-config cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/opt/eos ..
make -j$(nproc)
sudo make install
sudo cp ./programs/eosd/eosd /usr/bin/eosd    # Optional
sudo cp ./programs/eosc/eosc /usr/bin/eosc    # Optional
cp ../genesis.json ~/    # Move genesis.json to your home directory

修改 config.ini

cd ~/
eosd    # Ctrl+C after run to create config file
nano ./data-dir/config.ini

编辑config.ini,修改和添加下列代码


# 修改下列代码
genesis-json = "/home/USERNAME/genesis.json"    # 修改USERNAME为你的用户名
enable-stale-production = true    # 改成 true

增加下列代码

producer-name = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
plugin = eos::producer_plugin
plugin = eos::chain_api_plugin # 运行 eosc

运行 eosd

screen -S eosd
eosd

运行 eosc

eosc info

eosc 文档

https://eosio.github.io/eos/group__eosc.html
https://github.com/EOSIO/eos/issues/97

Note: Example contracts are located in ~/eos/contracts, for instance,

eosc setcode currency ./eos/contracts/currency/currency.wast ./eos/contracts/currency/currency.abi

一个合约实例 Here

Sort:  

Very informative.

我想知道国内的腾讯云、阿里云之类,能不能运行Steem节点,有试过的朋友吗?

没有试过,应该都可以的啊。

一个Docker就搞定了 不需要这么麻烦

Congratulations @leoliao! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard:
SteemitBoard World Cup Contest - Home stretch to the finals. Do not miss them!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @leoliao! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 65775.18
ETH 2600.82
USDT 1.00
SBD 2.68