目前网络上都是针对老版EOS2.0源码编译的文章,我在mac上参考这些文章编译,最后发现根本就不对,最新版本只需一条命令(./eosio_build.sh,依赖库会自动安装的)即可。我根据这些文章手动安装的库还导致如下问题,最后大部分时间都花在解决这个问题上。【官网安装文档传送门】

ItleaksDeMacbook-Pro:eos itleaks$ ./eosio_build.sh
fatal: destination path 'mongo-cxx-driver' already exists and is not an empty directory.
    Unable to clone MongoDB C++ driver at this time.
    Exiting now.

这个问题解决方案如下
sudo rm -rf /tmp/mongo*
cd /path/to/eos
rm -rf build/
git pull
git submodule update --init --recursive
./eosio_build.sh

如果还是不行,可以尝试重装brew,具体参考我的这篇博文【mac重装Homebrew】

如果出现下面的问题
 Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR)
执行下面的命令即可
brew unlink gettext && brew link --force gettext

现在开始跟着下面的步骤编译EOS搭建开发环境吧

下载源码
EOS 代码使用了三个子模块
插件管理模块 AppBase
区块链结构模块 ChainBase
WASM 模块
git clone https://github.com/eosio/eos --recursive
所以上面需要用recursive,如果没有带有recursive下载了eos,可以通过如下方式下载submodules
cd eos
git submodule update --init --recursive
国内目前从github下载源码速度很慢,可以参考我这篇博文【github访问慢和clone慢解决方案】提速

编译
编译其实很简单,就是执行./eosio_build.sh脚本
mac平台编译依赖homebrew工具,所以必须先安装好homebrew工具
    
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
 
如果你的电脑内存<8G会报如下错误

itleaks@itleaks-VirtualBox:~/projects/eos$ ./eosio_build.sh

    Beginning build version: 1.2
    2018年 05月 18日 星期五 07:13:36 UTC
    User: itleaks
    git head id: 29c30f10650102ffb000bb1a287dc285d582275f
    Current branch: master

    ARCHITECTURE: Linux

    OS name: Ubuntu
    OS Version: 16.04
    CPU speed: 3095.998Mhz
    CPU cores: 1
    Physical Memory: 1993 Mgb
    Disk install: /dev/sda1
    Disk space total: 47G
    Disk space available: 31G
    Your system must have 7 or more Gigabytes of physical memory installed.
    Exiting now.

如果你想绕开这个限制,可以修改相应的脚本文件
VirtualBox:~/projects/eos$ grep "Your system must have" . -rn
./scripts/eosio_build_ubuntu.sh:28:        printf "\tYour system must have 7 or more Gigabytes of physical memory installed.\n"
./scripts/eosio_build_darwin.sh:29:        echo "Your system must have 7 or more Gigabytes of physical memory installed."
./scripts/eosio_build_fedora.sh:25:        printf "\tYour system must have 7 or more Gigabytes of physical memory installed.\n"
./scripts/eosio_build_amazon.sh:21:        printf "\tYour system must have 7 or more Gigabytes of physical memory installed.\n"
./scripts/eosio_build_centos.sh:26:        printf "\n\tYour system must have 7 or more Gigabytes of physical memory installed.\n"

比如ubuntu平台就修改./scripts/eosio_build_ubuntu.sh文件,将下面的7000修改即可

编译时会自动下载依赖库

$./eosio_build.sh
Checking dependencies.
    Checking automake ...          automake NOT found.
    Checking Libtool ...          Libtool NOT found.
    Checking OpenSSL ...          OpenSSL NOT found.
    Checking llvm ...          llvm NOT found.
    Checking wget ...          wget NOT found.
    Checking CMake ...          CMake NOT found.
    Checking GMP ...          GMP NOT found.
    Checking gettext ...          gettext NOT found.
    Checking MongoDB ...          MongoDB NOT found.
    Checking Doxygen ...          Doxygen NOT found.
    Checking Graphviz ...          Graphviz NOT found.
    Checking LCOV ...          LCOV NOT found.
    Checking Python3 ...          python3 NOT found.

    The following dependencies are required to install EOSIO.

    1. automake\n\t2. Libtool\n\t3. OpenSSL\n\t4. llvm\n\t5. wget\n\t6. CMake\n\t7. GMP\n\t8. gettext\n\t9. MongoDB\n\t10. Doxygen\n\t11. Graphviz\n\t12. LCOV\n\t13. Python 3\n\t

    这个依赖库下载过程是非常慢,其中llvm耗时最久,最好的办法是使用vpn,否则真的就是龟速。

最后编译成功会显示如下信息:

测试验证
ubuntu@ip-172-31-28-214:/data/d01/data/eos$ export PATH=${HOME}/opt/mongodb/bin:$PATH
ubuntu@ip-172-31-28-214:/data/d01/data/eos$ /home/ubuntu/opt/mongodb/bin/mongod -f /home/ubuntu/opt/mongodb/mongod.conf &
[1] 10764
ubuntu@ip-172-31-28-214:/data/d01/data/eos$ cd /data/d01/data/eos/build; make test
Running tests...
Test project /data/d01/data/eos/build
      Start  1: test_cypher_suites
1/29 Test  #1: test_cypher_suites ..................   Passed    0.02 sec
      Start  2: validate_simple.token_abi
2/29 Test  #2: validate_simple.token_abi ...........   Passed    0.02 sec
      Start  3: validate_eosio.token_abi
3/29 Test  #3: validate_eosio.token_abi ............   Passed    0.03 sec
      Start  4: validate_eosio.msig_abi
4/29 Test  #4: validate_eosio.msig_abi .............   Passed    0.02 sec
      Start  5: validate_multi_index_test_abi
5/29 Test  #5: validate_multi_index_test_abi .......   Passed    0.03 sec
      Start  6: validate_eosio.system_abi
6/29 Test  #6: validate_eosio.system_abi ...........   Passed    0.02 sec
      Start  7: validate_identity_abi
7/29 Test  #7: validate_identity_abi ...............   Passed    0.03 sec
      Start  8: validate_identity_test_abi
8/29 Test  #8: validate_identity_test_abi ..........   Passed    0.03 sec
      Start  9: validate_stltest_abi
9/29 Test  #9: validate_stltest_abi ................   Passed    0.02 sec
      Start 10: validate_exchange_abi
10/29 Test #10: validate_exchange_abi ...............   Passed    0.02 sec
      Start 11: validate_test.inline_abi
11/29 Test #11: validate_test.inline_abi ............   Passed    0.02 sec
      Start 12: validate_hello_abi
12/29 Test #12: validate_hello_abi ..................   Passed    0.02 sec
      Start 13: validate_asserter_abi
13/29 Test #13: validate_asserter_abi ...............   Passed    0.02 sec
      Start 14: validate_infinite_abi
14/29 Test #14: validate_infinite_abi ...............   Passed    0.03 sec
      Start 15: validate_proxy_abi
15/29 Test #15: validate_proxy_abi ..................   Passed    0.02 sec
      Start 16: validate_test_api_abi
16/29 Test #16: validate_test_api_abi ...............   Passed    0.02 sec
      Start 17: validate_test_api_mem_abi
17/29 Test #17: validate_test_api_mem_abi ...........   Passed    0.02 sec
      Start 18: validate_test_api_db_abi
18/29 Test #18: validate_test_api_db_abi ............   Passed    0.03 sec
      Start 19: validate_test_api_multi_index_abi
19/29 Test #19: validate_test_api_multi_index_abi ...   Passed    0.03 sec
      Start 20: validate_eosio.bios_abi
20/29 Test #20: validate_eosio.bios_abi .............   Passed    0.02 sec
      Start 21: validate_noop_abi
21/29 Test #21: validate_noop_abi ...................   Passed    0.02 sec
      Start 22: validate_dice_abi
22/29 Test #22: validate_dice_abi ...................   Passed    0.02 sec
      Start 23: validate_tic_tac_toe_abi
23/29 Test #23: validate_tic_tac_toe_abi ............   Passed    0.02 sec
      Start 24: validate_payloadless_abi
24/29 Test #24: validate_payloadless_abi ............   Passed    0.02 sec

启动节点服务程序
 EOS主要有三个程序:
ubuntu@ip-172-31-28-214:/data/d01/data/eos/build$ ls programs/ -alh
total 52K
drwxrwxr-x  9 ubuntu ubuntu 4.0K May 18 07:45 .
drwxrwxr-x 16 ubuntu ubuntu 4.0K May 18 08:00 ..
drwxrwxr-x  3 ubuntu ubuntu 4.0K May 18 07:52 cleos
drwxrwxr-x  3 ubuntu ubuntu 4.0K May 18 07:50 keosd
drwxrwxr-x  3 ubuntu ubuntu 4.0K May 18 07:53 nodeos
cloes:客户端命令行交互模块,用于解析用户命令,根据具体命令请求调用相应的接口,例如查看区块信息、操作钱包等等。
nodeos:服务器端,也就是区块生产节点,用于接受客户端的远端请求,并打包区块,主要包含四个插件,chain_plugin、http_plugin、net_plugin、producer_plugin。
keosd:钱包管理模块,主要包括三个插件,wallet_plugin、wallet_api_plugin、http_plugin。

启动nodeos,命令如下
./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin 

如果不带参数执行nodeos程序,会如下错误

这是因为没有为nodeos程序配置各种插件,修改config文件配置插件
vi ~/.local/share/eosio/nodeos/config/config.ini

需要修改如下红色框的内容

重启启动nodeos程序,结果如下,可见已经能挖出block了

安装开发工具
    比如eosiocpp工具,Include, library库安装,这些在开发智能合约时用的上

cd build
sudo make install

EOS源码系列
    https://blog.csdn.net/itleaks/article/category/7763923
---------------------
作者:ITleaks
来源:CSDN
原文:https://blog.csdn.net/ITleaks/article/details/80367131
版权声明:本文为博主原创文章,转载请附上博文链接!

1.EOS源码编译运行的更多相关文章

  1. Flink 源码解析 —— 源码编译运行

    更新一篇知识星球里面的源码分析文章,去年写的,周末自己录了个视频,大家看下效果好吗?如果好的话,后面补录发在知识星球里面的其他源码解析文章. 前言 之前自己本地 clone 了 Flink 的源码,编 ...

  2. eos源码编译

    编译源码 运行代码 在阿里云 纽约服务器上运行没有出现任何问题. 在其他电脑上出现很多问题. 搜集到的问题如下: 随着EOSIO软件越来越成熟,后来的开发者也越来越幸福.EOS相关源码的编译和运行变得 ...

  3. 《Flink 源码解析》—— 源码编译运行

    更新一篇知识星球里面的源码分析文章,去年写的,周末自己录了个视频,大家看下效果好吗?如果好的话,后面补录发在知识星球里面的其他源码解析文章. 前言 之前自己本地 clone 了 Flink 的源码,编 ...

  4. VsCode源码编译运行

    参考链接官方文档:https://github.com/Microsoft/vscode/wiki/How-to-Contribute 一.准备环境 Git Node.js(64位,>= 8.1 ...

  5. vscode源码编译运行打包使其由英文变为中文

    vscode默认是英文,如果你想让其变为中文,可参考这个链接:https://blog.csdn.net/testcs_dn/article/details/75070415 最近发现一个很奇怪的问题 ...

  6. 源码编译运行android emulator

    source buile/envsetup.sh lunch sdk-eng make sdk -j2 编译完之后,sdk安装在了下面的目录里 ANDROIID_DIR/out/host/linux- ...

  7. Android7.0源码编译运行指南【转】

    见连接: http://blog.csdn.net/HardReceiver/article/details/52650303

  8. 一、Vs2019扩展多了 导航到反编译的源码中运行

    一.导航到反编译的源码中运行

  9. Android stdio Apktool源码编译

    Android Apktool源码编译 标签(空格分隔): Android Apktool 源码编译 需求 习惯NetBeans调试smali需要用Apktool反编译apk,需要用-d的参数才能生成 ...

随机推荐

  1. Appstore|IPA

    ios提审报错:No suitable application records were found. Verify your bundle identifier 'xx' is correct - ...

  2. L2-001 紧急救援(dijkstra算法)

    题目: 作为一个城市的应急救援队伍的负责人,你有一张特殊的全国地图.在地图上显示有多个分散的城市和一些连接城市的快速道路.每个城市的救援队数量和每一条连接两个城市的快速道路长度都标在地图上.当其他城市 ...

  3. CF1066D Boxes Packing(二分答案)

    题意描述: 你有$n$个物品,每个物品大小为$a_i$,$m$个盒子,每个盒子的容积为$k$.$Maksim$先生想把物品装入盒子中.对于每个物品,如果能被放入当前的盒子中,则放入当前盒子,否则换一个 ...

  4. 异常笔记:运行hdfs copyFromLocal 上传文件报错

    把本地文件系统,复制到dfs文件系统时报错的错 [hadoop@localhost ~]$ hdfs dfs -copyFromLocal /home/hadoop/mk.txt /xg_test/ ...

  5. Action与Func 用法

    //vs2017 + framework4.6.2 //zip    https://github.com/chxl800/ActionFuncDemo //源文件git   https://gith ...

  6. jQuery实现简单的拼图游戏

    一,实现拼图的搭建: <div class="box"> <table id="table1" class="mytable&quo ...

  7. JavaScript 中 Property 和 Attribute 的区别详解

    property 和 attribute非常容易混淆,两个单词的中文翻译也都非常相近(property:属性,attribute:特性),但实际上,二者是不同的东西,属于不同的范畴. property ...

  8. 纯js轮播图练习-1

    偶尔练习,看视频自己学着做个简单的纯JS轮播. 简单的纯js轮播图练习-1. 样子就是上面图片那样,先不管好不好看,主要是学会运用和理解轮播的原理 掌握核心的理论知识和技术的操作,其他的都可以在这个基 ...

  9. MongoDB 4.0.6 Manual

    General mongod options: -v [ --verbose ] [=arg(=v)] be more verbose (include multiple times for more ...

  10. ISAP学习笔记

    学完了ISAP,感觉心情舒畅,毕竟ISAP比Dinic好一点. 说到底ISAP其实是Dinic(不熟悉Dinic的人去我的博客找猴子课堂----最大流与最小割(看看思想),已经置顶)优化版,熟悉的人知 ...