美文网首页
ChainX 搭建

ChainX 搭建

作者: LaxChan | 来源:发表于2018-12-13 00:55 被阅读0次

    参考链接

    环境

    • 服务器系统
      CentOS
    • Rust & WebAssembly
      安装命令
    curl https://sh.rustup.rs -sSf | sh
    安装完成后,相应的执行命令路径亦写到安装用户的系统配置文件中,要生效直接执行命令:
    source ~/.bash_profile
    
    $ rustup update nightly
    $ rustup target add wasm32-unknown-unknown --toolchain nightly
    $ rustup update stable
    $ cargo install --git https://github.com/alexcrichton/wasm-gc
    

    验证

    rustc --version
    输出:
    rustc 1.30.1 (1433507eb 2018-11-07)
    

    cmake & pkg-config & openssl-devel

    cmake
    $ wget https://cmake.org/files/v3.13/cmake-3.13.1.tar.gz
    $ tar zxvf cmake-3.13.1.tar.gz
    $ cd cmake-3.13.1
    $ ./bootstrap
    $ gmake
    $ gmake install
    
    pkg-config
    $ wget https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
    $ tar zxvf pkg-config-0.29.2.tar.gz
    $ cd pkg-config-0.29.2
    $ ./configure --with-internal-glib
    $ make & make install 
    
    openssl-devel
    $ yum install openssl-devel 
    

    ChainX源码安装

    • 下载源码&编译
    ##下载
    $ git clone https://github.com/chainx-org/ChainX ~/ChainX
    $ cd ~/ChainX
    ## 编译
    $ cargo +nightly build --release
    ## 代码路径 
    target/release/chainx
    
    编译完成后目录结构
    • 运行
    RUST_LOG=info ./chainx --chainspec=dev --telemetry --name=YOUR_NAME --bootnodes=/ip4/47.93.16.189/tcp/20222/p2p/QmRdBJk8eVPjkHcxZvRAUZdWtTq96mWivJFc7tpJ8fUEGU --db-path=/tmp/chainx
     name:节点名称
    db-path:本地存储路径
    
    通过官方web钱包创建个人账号:
    http://wallet.chainx.org
    保存seed及address 
    
    启动命令添加--key=<seed> validator :
    RUST_LOG=info ./chainx --chainspec=dev --telemetry --name=YOUR_NAME --bootnodes=/ip4/47.93.16.189/tcp/20222/p2p/QmRdBJk8eVPjkHcxZvRAUZdWtTq96mWivJFc7tpJ8fUEGU --db-path=/tmp/chainx --key=YOUR_SEED validator 
    
    • 异常信息
      Compiling openssl-sys v0.9.36
    error: failed to run custom build command for `openssl-sys v0.9.36`
    process didn't exit successfully: `/data/chen/rust/ChainX/target/release/build/openssl-sys-e59f5626f2a0d7bb/build-script-main` (exit code: 101)
    --- stdout
    cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
    cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
    cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
    cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
    cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
    cargo:rerun-if-env-changed=OPENSSL_DIR
    run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit code: 1\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'openssl\' found\n"
    
    --- stderr
    thread 'main' panicked at '
    
    Could not find directory of OpenSSL installation, and this `-sys` crate cannot
    proceed without this knowledge. If OpenSSL is installed and this crate had
    trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
    compilation process.
    
    Make sure you also have the development packages of openssl installed.
    For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
    
    If you're in a situation where you think the directory *should* be found
    automatically, please open a bug at https://github.com/sfackler/rust-openssl
    and include information about your system as well as this message.
    
       $HOST = x86_64-unknown-linux-gnu
       $TARGET = x86_64-unknown-linux-gnu
       openssl-sys = 0.9.36
    
    ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.36/build/main.rs:265:9
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    
    error: failed to run custom build command for `openssl-sys v0.9.36`
    process didn't exit successfully: `/data/chen/rust/ChainX/target/release/build/openssl-sys-e59f5626f2a0d7bb/build-script-main` (exit code: 101)
    --- stdout
    cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
    cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
    cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
    cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
    cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
    cargo:rerun-if-env-changed=OPENSSL_DIR
    
    --- stderr
    thread 'main' panicked at 'OpenSSL include directory does not exist: /data/chen/rust/libs/openssl/include', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.36/build/main.rs:65:9
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    

    解决方式:

    配置OPENSSL_DIR
       编辑配置文件:vim ~/.bash_profile 
       添加如下配置:
          OPENSSL_DIR=/root/chainx/openssl
          export OPENSSL_DIR
       保存修改,并加载配置文件:source ~/.bash_profile
    
    创建OPENSSL_DIR目录,并在该目录下软链对应的.so文件(lib文件)和 .h(include 文件)
    查找openssl的so文件:
        查看openssl命令位置:which openssl
          结果:/usr/bin/openssl
        查看命令链接的so文件:ldd /usr/bin/openssl
          结果:libssl.so.10 => /lib64/libssl.so.10  (见图1,找到所需目录/lib64)
    创建软链:  ln -s /lib64 /root/chainx/openssl/lib
    
    查找openssl的include文件:find / -name "openssl"|grep include
        结果:/usr/local/ssl/include/openssl(见图2,找到所需目录)
     创建软链: ln -s /usr/local/ssl/include/openssl /root/chainx/openssl/include
    
    图1
    图2

    相关文章

      网友评论

          本文标题:ChainX 搭建

          本文链接:https://www.haomeiwen.com/subject/jffzcqtx.html