-1

Mac OS Sierra Apple LLVM version 8.0.0 (clang-800.0.42.1) gcc version c++-9 (Homebrew GCC 9.2.0_2) 9.2.0

I am trying to compile a test program that uses https://github.com/binance-exchange/binacpp which uses microsoft's jsoncpp https://github.com/open-source-parsers/jsoncpp and the openssl, curl, websockets, json libraries i am running into a linking problem and it seems to me that none of the symbols are resolved. cant figure out why. Might be due to the ugly setup...

ugly setup: - microsoft (jsoncpp) uses some tech that is not supported by llvm/clang so it suggests using gcc and microsoft's packetmanager vcpkg. with gcc the source compiled into a static library libjsoncpp.a which i copied into my testprogramm's dir. - compiled binacpp sources with gcc -c into objectfiles and used ar rcs libbinacpp *.o to create another static library - included include and lib dirs for openssl that is for some reason not found in the usual dirs, als well as the header files for libjsoncpp directly

whole command:

/usr/local/opt/gcc/bin/c++-9 test.cpp libbinacpp.a libjsoncpp.a  
-I/Users/N/Downloads/vcpkg/packages/jsoncpp_x64-osx/include
-I/usr/local/Cellar/openssl@1.1/1.1.1d/include 
-L/usr/local/Cellar  /openssl@1.1/1.1.1d/lib -lwebsockets -ljson -lcurl -lssl 

the whole thing gives me lots of errors. Have no idea whats going wrong... Any help appreciated.

Regards.

errors (small portion):

Undefined symbols for architecture x86_64: -"_EVP_sha256", referenced from: - hmac_sha256[abi:cxx11](char const*, char const*) in libbinacpp.a(binacpp_utils.o) - "_HMAC", referenced from: - hmac_sha256[abi:cxx11](char const*, char const*) in libbinacpp.a(binacpp_utils.o) - "_SHA256_Final", referenced from: - sha256[abi:cxx11](char const*) in libbinacpp.a(binacpp_utils.o) - "_SHA256_Init", referenced from: - sha256[abi:cxx11](char const*) in libbinacpp.a(binacpp_utils.o) - "_SHA256_Update", referenced from: - sha256[abi:cxx11](char const*) in libbinacpp.a(binacpp_utils.o) - "Json::Reader::parse(std::__cxx11::basic_string, -std::allocator > const&, Json::Value&, bool)", referenced from: - BinaCPP::get_exchangeInfo(Json::Value&) in libbinacpp.a(binacpp.o) - BinaCPP::get_serverTime(Json::Value&) in libbinacpp.a(binacpp.o) - BinaCPP::get_allPrices(Json::Value&) in libbinacpp.a(binacpp.o) - BinaCPP::get_allBookTickers(Json::Value&) in libbinacpp.a(binacpp.o) - BinaCPP::get_depth(char const*, int, Json::Value&) in libbinacpp.a(binacpp.o) - BinaCPP::get_aggTrades(char const*, int, long, long, int, Json::Value&) in -libbinacpp.a(binacpp.o) - BinaCPP::get_24hr(char const*, Json::Value&) in libbinacpp.a(binacpp.o) - ... - "Json::operator<<(std::basic_ostream >&, Json::Value const&)", -referenced from: - _main in ccsPSRMm.o - "Json::Value::asStringabi:cxx11 const", referenced from: - BinaCPP::get_price(char const*) in libbinacpp.a(binacpp.o) - BinaCPP::get_bookTicker(char const*, Json::Value&) in libbinacpp.a(binacpp.o) - "std::__1::basic_string, std::__1::allocator

... a lot more errors ....

ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status

Mohammad
  • 1,549
  • 1
  • 15
  • 27
stdout
  • 79
  • 1
  • 6

1 Answers1

0

it seems you just forgot to include your libraries in the project, please reference to this question, in case you are using Xcode it mentioned there by pictures how to do it.

walid barakat
  • 455
  • 1
  • 6
  • 17
  • not using xcode. please read the description of the problem. clang does not work on the code. i am using the command /usr/local/opt/gcc/bin/c++-9 test.cpp libbinacpp.a libjsoncpp.a -I/Users/N/Downloads/vcpkg/packages/jsoncpp_x64-osx/include -I/usr/local/Cellar/openssl@1.1/1.1.1d/include -L/usr/local/Cellar /openssl@1.1/1.1.1d/lib -lwebsockets -ljson -lcurl -lssl – stdout Dec 26 '19 at 13:24
  • which includes the libraries – stdout Dec 26 '19 at 13:25
  • symbol Json::Reader::parse() is not found during linking yet nm -gDC libjsoncpp.a shows it to be present. So it should be found. Have no idea whats wrong. – stdout Dec 27 '19 at 16:41
  • can you please write down the command you use to compile and link, or if you use an IDE not command line, tell me what IDE are you using? – walid barakat Dec 29 '19 at 14:28
  • 1
    dude its written there twice: – stdout Dec 29 '19 at 21:15
  • /usr/local/opt/gcc/bin/c++-9 test.cpp libbinacpp.a libjsoncpp.a -I/Users/N/Downloads/vcpkg/packages/jsoncpp_x64-osx/include -I/usr/local/Cellar/openssl@1.1/1.1.1d/include -L/usr/local/Cellar /openssl@1.1/1.1.1d/lib -lwebsockets -ljson -lcurl -lssl – stdout Dec 29 '19 at 21:16