Libbitcoin
無法使用比特幣/bitcoin.hpp
libbitcoin 庫似乎已經安裝得很好。但以下程式碼似乎無法包含 bitcoin/bitcoin.hpp
#include<bitcoin/bitcoin.hpp> #include<iostream> using namespace bc; int main() { block_type blk = genesis_block(); std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl; return 0; }
錯誤:
g++ -o test test.cpp $(pkg-config --cflags --libs libbitcoin) test.cpp: In function ‘int main()’: test.cpp:5:5: error: ‘block_type’ was not declared in this scope block_type blk = genesis_block(); ^~~~~~~~~~ test.cpp:5:5: note: suggested alternative: ‘clock_t’ block_type blk = genesis_block(); ^~~~~~~~~~ clock_t test.cpp:6:45: error: ‘blk’ was not declared in this scope std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl; ^~~ test.cpp:6:45: note: suggested alternative: ‘brk’ std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl; ^~~ brk test.cpp:6:27: error: ‘hash_block_header’ was not declared in this scope std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl; ^~~~~~~~~~~~~~~~~ test.cpp:6:16: error: ‘encode_hex’ was not declared in this scope std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl; ^~~~~~~~~~
我能夠執行此程式碼:
#include <bitcoin/bitcoin.hpp> int main() { bc::ec_secret decoded; bc::decode_base16(decoded, "038109007313a5807b2eccc082c8c3fbb988a973cacf1a7df9ce725c31b"); }
按照這個<https://github.com/libbitcoin/libbitcoin#debianubuntu>
在 /home/x/dir 中編譯後執行:
g++ helloworld.cpp -I/home/dev/bitcoin-lib/include /home/dev/bitcoin-lib/lib/libbitcoin.a /home/dev/bitcoin-lib/lib/libboost_system.a /home/dev/bitcoin-lib/lib/libbitcoin.a /home/dev/bitcoin-lib/lib/libboost_program_options.a /home/dev/bitcoin-lib/lib/libboost_regex.a
- 我們需要告訴 g++ #include 語句的標題在哪裡
- 我們需要告訴 g++ 有哪些庫:libbitcoin.a 等