-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Labels
Description
#Installation
$ brew install libbitcoin
$ brew install libbitcoin-client
$ brew install zeromq
$ brew install boost
#Run command
/usr/bin/clang++ -std=c++11 btc.cpp -L/usr/local/opt/libbitcoin/lib -lbitcoin -L/usr/local/opt/libbitcoin-client/lib -lbitcoin-client -L/usr/local/opt/boost/lib -lboost_system -L/usr/local/opt/zmq/lib/ -lzmq -o btc -v
#File Contents
#include <cstddef>
#include <bitcoin/bitcoin.hpp>
#include <bitcoin/client.hpp>
#include <string.h>
#include <iostream>
using namespace bc;
uint64_t balancer(const chain::history::list &rows)
{
uint64_t unspent_balance = 0;
for (const auto &row : rows)
{
// spend unconfirmed (or no spend attempted)
if (row.spend.hash() == null_hash)
unspent_balance += row.value;
}
return unspent_balance;
}
void getBalance(wallet::payment_address address)
{
client::connection_type connection = {};
connection.retries = 3;
connection.timeout_seconds = 8;
connection.server = config::endpoint("tcp://testnet3.libbitcoin.net:19091");
client::obelisk_client client(connection);
static const auto on_done = [](const chain::history::list &rows) {
uint64_t balance = balancer(rows);
std::cout << encode_base10(balance, 8) << std::endl;
};
static const auto on_error2 = [](const code ec) {
std::cout << "Error Code: " << ec.message() << std::endl;
};
if (!client.connect(connection))
{
std::cout << "Fail" << std::endl;
}
else
{
std::cout << "Connection Succeeded" << std::endl;
}
client.blockchain_fetch_history3(on_error2, on_done, address);
client.wait();
}
int main()
{
wallet::payment_address addy("mnrnjVFimDFrNkszzMtecr4yrMKmEuMRbv");
getBalance(addy);
}
#Error Generated
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx11.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name btc.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return -fno-rounding-math -munwind-tables -target-sdk-version=11.3 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -debugger-tuning=lldb -target-linker-version 650.9 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Users/regarm/Dev/go/github.com/regarm/cheapskate -ferror-limit 19 -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -mllvm -disable-aligned-alloc-awareness=1 -o /var/folders/6w/g4kb03991xxdr07p37p4_w4r0000gn/T/btc-7a58b8.o -x c++ btc.cpp
clang -cc1 version 12.0.5 (clang-1205.0.22.9) default target x86_64-apple-darwin20.3.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -platform_version macos 11.0.0 11.3 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o btc -L/usr/local/opt/libbitcoin/lib -L/usr/local/opt/libbitcoin-client/lib -L/usr/local/opt/boost/lib -L/usr/local/opt/zmq/lib/ -L/usr/local/lib /var/folders/6w/g4kb03991xxdr07p37p4_w4r0000gn/T/btc-7a58b8.o -lbitcoin -lbitcoin-client -lboost_system -lzmq -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"libbitcoin::protocol::zmq::socket::~socket()", referenced from:
libbitcoin::client::obelisk_client::~obelisk_client() in btc-7a58b8.o
"libbitcoin::protocol::zmq::context::~context()", referenced from:
libbitcoin::client::obelisk_client::~obelisk_client() in btc-7a58b8.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any help would be appreciated.