编译源码 运行代码 在阿里云 纽约服务器上运行没有出现任何问题。node
在其余电脑上出现不少问题。
搜集到的问题以下:
随着EOSIO软件愈来愈成熟,后来的开发者也愈来愈幸福。EOS相关源码的编译和运行变得异常简单。并且官方提供了开发者文档EOSIO Developer Portal
,可以帮助更好的理解和使用。不过文档全面而细节不足,也缺乏一些问题状况的处理。知易行难,上手试试吧。git
环境说明
本文测试过的编译环境:
Ubuntu 16.04 LTS
Ubuntu 16.04.4 LTS
macOS High Sierra(10.13.3)github
源码下载
本文撰写时,最新的release为v1.0.6shell
(1)下载代码json
git clone https://github.com/EOSIO/eos --recursive
1
若是忘记使用“–recursive”,可在克隆下的eos目录中执行ubuntu
git submodule update --init --recursive
1
(2)切换到v1.0.6api
git checkout v1.0.6
1
编译
在eos目录中,执行eosio_build.sh。
若是有好的***工具请提早配置好,执行下面的命令后,会检查系统环境,下载所依赖的软件工具。若有问题可看后面的问题汇总与处理。服务器
cd eos
./eosio_build.sh
1
2
比较顺利的话,会看到以下的提示:网络
使用Ubuntu比较顺利,就是下载和编译耗时,基本没有啥问题。app
启动节点
若是仅想搭建本地的单节点测试网,进入eos的build目录,执行sudo make install。像我这样本身同步主网、测试网,外加本身单节点测试的,暂时先不执行install了,避免混乱,而是在build各个目录里面执行。
这里先说明单节点测试状况
cd build/programs/nodeos
./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
1
2
看到以下信息说明已经开始生产块了
查看网络信息
既然已经开始生产块了,那另起一个shell终端,执行cleos查看当前网络信息
cd build/programs/cleos
./cleos get info
1
2
看到以下网络信息:
{
"server_version": "79651199",
"chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
"head_block_num": 20,
"last_irreversible_block_num": 19,
"last_irreversible_block_id": "000000138960dec18c0daf35042fc8a180e884241cd5827335206a441992fa86",
"head_block_id": "00000014ef94b3c0b066454bec196c8c4f1ac4115c8c9cd43294fc0e2ea596cd",
"head_block_time": "2018-06-22T23:57:02.000",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 203830,
"virtual_block_net_limit": 1068689,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
好了,能够开始你的各类测试了,测试命令参考官网cleos reference
生成的块和配置信息默认在以下目录:
Mac OS: ~/Library/Application Support/eosio/nodeos/
Linux: ~/.local/share/eosio/nodeos/
简单理解下单节点网络
借用官网图:
eos的build目录里生成的可执行程序不少,经常使用到的:
nodeos :经过配置不一样插件,启动节点,同步EOS网络数据或者本身生成块,也可做为API节点供调用
keosd:管理钱包,钱包中包含EOS公私钥对信息
cleos:命令行交互接口,链接钱包与EOS网络,执行查看网络信息,推送交易信息,部署智能合约等
eosiocpp:编译智能合约,生成wasm文件及abi文件
1.内存空间不足
遇到Your system must have 7 or more Gigabytes of physical memory installed
执行eosio_build.sh时,会检查系统内存至少7G,修改script下对应系统的脚本便可。scripts/eosio_build_ubuntu.sh的diff以下:
if [ "${MEM_MEG}" -lt 7000 ]; then
if [ "${MEM_MEG}" -lt 3000 ]; then printf "\\tYour system must have 7 or more Gigabytes of physical memory installed.\\n" printf "\\tExiting now.\\n" exit 11
CMake Error at libraries/wasm-jit/Source/Runtime/CMakeLists.txt:26 (find_package):
Could not find a package configuration file provided by "LLVM" (requested
version 4.0) with any of the following names:
1
2
3
参考https://github.com/EOSIO/eos/issues/43
根据提示找到llvm 4.0的路径,可利用tab在此路径下查找
ll /usr/local/Cellar/llvm/4.
而后经过export到环境变量中
export LLVM_DIR=/usr/local/Cellar/llvm/4.0.0_1/lib/cmake
3.Failed to find Gettext libintl
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/Applications/CMake.app/Contents/share/cmake-3.11/Modules/FindIntl.cmake:47 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
programs/cleos/CMakeLists.txt:29 (find_package)
1
2
3
4
5
6
参考https://github.com/EOSIO/eos/issues/2174
执行brew link gettext –force
顺便补充万一测试个hello world的智能合约,发现编译有问题
4.没法找到依赖的头文件及库
hello.cpp:1:10: fatal error: 'eosiolib/eosio.hpp' file not found
^~~~~~~~~~~~~~~~~~~~
1 error generated.
1
2
3
4
简单的是在eos源码下编译后的build目录中,执行sudo make install后便可。
后续再写如何链接EOS主网,JungleTestnet测试网络及如何配置节点等信息,好比genesis.json,block数据等等。