新手问答 编译合约遇到问题

liujinming · August 08, 2018 · Last by liujinming replied at August 08, 2018 · 5890 hits

这个问题怎么解决呀 编译合约的时候报错 fatal error: 'eosiolib/eosio.hpp' file not found

依然出错 步骤是这样子的: 1.git clone https://github.com/eosio/eos --recursive 2.cd eos 3.git submodule update --init --recursive

  1. sudo ./eosio_build.sh 5.cd build 6.sudo make install

然后到/eos/contracts 目录下,新建文件夹 demo
vim demo.cpp 内容如下 #include #include using namespace eosio;

class hello : public eosio::contract { public: using contract::contract; /// @abi action void hi( account_name user ) { print( "Hello, ", name{user} ); } };

EOSIO_ABI( hello, (hi) )

编译:eosiocpp -o demo.wast demo.cpp ljm@ubuntu:~/work/EOS2/eos/contracts/demo$ eosiocpp -o demo.wast demo.cpp demo.cpp:1:10: fatal error: 'eosiolib/eosio.hpp' file not found #include ^~~~~~~~~~~~~~~~~~~~ 1 error generated.

环境变量:export EOSIO_PATH=/usr/local/eosio/bin export PATH=$EOSIO_PATH:$PATH

echo $PATH /usr/local/eosio/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

为啥最后还是出错呢?

source ~/.bashrc 刷新了吗? /usr/local/eosio/bin 目录存在吧

刷新了

root@ubuntu:/# ll /usr/local/eosio/bin total 101860 drwxr-xr-x 2 root root 4096 Aug 8 02:46 ./ drwxr-xr-x 7 root root 4096 Aug 6 23:09 ../ -rwxr-xr-x 1 root root 8732912 Aug 8 00:00 cleos* -rwxr-xr-x 1 root root 27485864 Aug 8 00:00 eosio-abigen* -rwxr-xr-x 1 root root 5019 Aug 8 02:46 eosiocpp* -rwxr-xr-x 1 root root 5577376 Aug 8 00:00 eosio-launcher* -rwxr-xr-x 1 root root 2521128 Aug 7 23:43 eosio-s2wasm* -rwxr-xr-x 1 root root 699088 Aug 7 23:46 eosio-wast2wasm* -rwxr-xr-x 1 root root 8021328 Aug 8 00:00 keosd* -rwxr-xr-x 1 root root 51233088 Aug 7 23:59 nodeos*

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up