安裝:
安裝完之后 會產生 eosio-cpp_, eosio-cc, eosio-ld, eosio-pp, and _eosio_abigen (These are the C++ compiler, C compiler, linker, postpass tool and ABI generator.) 這些交互工具。
// step 1 $ git clone --recursive https://github.com/eosio/eosio.cdt
PS:整個克隆過程很慢,如果中斷進入項目根目錄,執行git submodule update --init --recursive繼續下載。
// step 2 // ./build.sh <CORE_SYMBOL> coresymbol可以理解為鏈名稱 這里用eos $ ./build.sh EOS
build完成之后會出現以下界面:
___ ___ ___ ___
/ /\ / /\ / /\ ___ / /\
/ /:/_ / /::\ / /:/_ / /\ / /::\
/ /:/ /\ / /:/\:\ / /:/ /\ / /:/ / /:/\:\
/ /:/ /:/_ / /:/ \:\ / /:/ /::\ /__/::\ / /:/ \:\
/__/:/ /:/ /\ /__/:/ \__\:\ /__/:/ /:/\:\ \__\/\:\__ /__/:/ \__\:\
\ \:\/:/ /:/ \ \:\ / /:/ \ \:\/:/~/:/ \ \:\/\ \ \:\ / /:/
\ \::/ /:/ \ \:\ /:/ \ \::/ /:/ \__\::/ \ \:\ /:/
\ \:\/:/ \ \:\/:/ \__\/ /:/ /__/:/ \ \:\/:/
\ \::/ \ \::/ /__/:/ \__\/ \ \::/
\__\/ \__\/ \__\/ \__\/
For more information:
EOSIO website: https://eos.io
安裝:
// step 3 sudo ./install.sh
安裝完后 同樣會出現安裝成功畫面, 這一步install會將下列可執行工具連接到 bin目錄下
llvm-ranlib
llvm-ar
llvm-objdump
llvm-readelf
eosio-cc
eosio-cpp
eosio-ld
eosio-pp
eosio-abigen
wasm2wat
wat2wasm
編譯:
在路徑eosio.cdt/examples 有hello合約的示例
#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
using namespace eosio;
class hello : public eosio::contract {
public:
using contract::contract;
[[eosio::action]]
void hi( name user ) {
print("Hello World",name{user});
}
};
EOSIO_DISPATCH( hello, (hi))
1 編譯wasm文件
$ eosio-cpp hello.cpp -o hello.wasm
2 編譯abi文件
// 1 在編譯wasm文件的同時加上--abigen flag可以同時編譯abi文件 $ eosio-cpp hello.cpp -o hello.wasm --abigen // 2 直接使用eosio-abigen 編譯 $ eosio-abigen hello.cpp --output=hello.abi
