EOSIO 1.0.7 编译配置运行

Posted joenchen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EOSIO 1.0.7 编译配置运行相关的知识,希望对你有一定的参考价值。

EOS主网已经上线,但是市面上还没有特别好用的钱包,所以只能自己动手丰衣足食了,在编译运行EOS代码的时候遇到不少的问题,这边记录一下。 使用Ubuntu 16.04在本地编译是没有遇到什么问题的,基本上一条命令就编译过去了,但是由于大部分的EOS节点都在国外,所以同步区块特别慢,所以还是买了一个美国的ECS,我购买是阿里云硅谷的服务器,github同步的时候十几M一秒,在国内是不敢想象的。

 

如果是在本地的ubuntu 16.04编译的话,基本上3条命令就可以编译出来了,跟着官方文档,没有出现什么意外

https://github.com/EOSIO/eos/wiki/Local-Environment#2-building-eosio

git clone https://github.com/EOSIO/eos --recursive
cd ~/eos
./eosio_build.sh 

apt update apt upgrade之后运行上面3条命令,基本没有遇到问题。都能直接过。我主要记录一下在阿里云的服务器上编译的问题。购买的是阿里云的ubuntu 16.04版本服务器,首先一个是云服务器只有2G内存,40G硬盘,编译的时候报错内存和硬盘不够,修改eosio_build_ubuntu.sh文件

vi scripts/eosio_build_ubuntu.sh
 
# if [ "${MEM_MEG}" -lt 7000 ]; then
# printf "\tYour system must have 7 or more Gigabytes of physical memory installed.\n"
# printf "\tExiting now.\n"
# exit 1
# fi
 
# if [ "${DISK_AVAIL%.*}" -lt "${DISK_MIN}" ]; then
# printf "\tYou must have at least %sGB of available storage to install EOSIO.\n" "${DISK_MIN}"
# printf "\tExiting now.\n"
# exit 1
# fi

把这些检测都注释掉,然后就可以运行./eosio_build.sh了,然后中间又报错

make: the ‘-j‘ option requires a positive integer argument
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can‘t be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don‘t start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don‘t actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don‘t remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make‘s internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don‘t echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.
 
This program built for x86_64-pc-linux-gnu
Report bugs to <[email protected]>
    Error compiling LLVM and clang with EXPERIMENTAL WASM support.1
 
    Exiting now.

我试了一下,从mongo-c-driver 到llvm全部出错,这个应该是make的问题?好吧,看来脚本没法搞了,就自己手动一个一个编译。运行./eosio_build.sh的时候哪个出错,就在tmp目录下根据下面这个文本教程做就可以了。 只是有一个问题,mongo-cxx-driver驱动不能使用教程的最新版。

https://bihu.com/article/179190

把git clone https://github.com/mongodb/mongo-cxx-driver.git –branch releases/stable –depth 1

换成git clone https://github.com/mongodb/mongo-cxx-driver.git –branch releases/v3.2 –depth 1

最新版本的mongo-cxx-driver驱动依赖高版本的 libbson 库,我们换成3.2就可以了,不然编译会失败。

从mongo-c-driver mongo-cxx-driver 到secp256k1-zkp到 llvm我都是手动编译的,另外根据那个教程在编译llvm的时候也有问题,因为EOS的检测路径改了,在script/eosio_build_ubuntu.sh目录下面看到有这个命令

printf "\n\tChecking for LLVM with WASM support.\n"
       if [ ! -d "${HOME}/opt/wasm/bin" ]; then
               # Build LLVM and clang with WASM support:
               printf "\tInstalling LLVM with WASM\n"
               if ! cd "${TEMP_DIR}"
               then
                       printf "\n\tUnable to cd into directory %s.\n" "${TEMP_DIR}"
                       printf "\n\tExiting now.\n"
                       exit 1;
               fi
               if ! mkdir "${TEMP_DIR}/llvm-compiler"  2>/dev/null
               then

检测的是home目录下的文件,所以根据上面的教程在llvm cmake的时候需要改动一下,将

cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX=.. -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ..

改成

cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX=”${HOME}/opt/wasm” -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../

安装目录改到了home目录下面才能被EOS的eosio_build_ubuntu.sh检测到。我日,搞到这里才发现之前为什么make会失败,之前的make失败是因为本地ubuntu 的shell都有这个变量${JOBS}在阿里云的机器上没有所以失败才会产生之前的make失败。。。惨痛的教训,用vi打开eosio_build_ubuntu.sh输入以下命令

:0, $s/make -j”${JOBS}”/make -j2/g

这条命令的意思是把所有的make -j”${JOBS}”替换成make -j2因为我买的阿里云服务器是双核的,你可以根据具体情况自己修改。这样就可以像本地一样直接编译了。不过还好,也算是手工搞了一遍,把EOS依赖库都熟悉了一遍,不过搞了几天,这个代价有点大。趟了一路的雷!!!

以上是关于EOSIO 1.0.7 编译配置运行的主要内容,如果未能解决你的问题,请参考以下文章

EOS私有链搭建

EOS私有链搭建

eosio 编译与部署

错误 3080006:EOSIO 区块链中的交易时间过长

Android 逆向Android 逆向通用工具开发 ( Android 平台运行的 cmd 程序类型 | Android 平台运行的 cmd 程序编译选项 | 编译 cmd 可执行程序 )(代码片段

如何有条件地将 C 代码片段编译到我的 Perl 模块?