0

I'm trying to run some example code from this repository

When going to the example folder (/binacpp/example) and run i.e.

 ./example.run.sh

It works. However when I update the file (even with just an extra space in a comment) and try to recompile the program by typing:

 make example

Then I get this error:

Making example


g++ -I../lib/libcurl-7.56.0/include -I../lib/jsoncpp-1.8.3/include -I../lib/libwebsockets-2.4.0/include -I../lib/libbinacpp/include \
example.cpp \
-L../lib/libcurl-7.56.0/lib \
-L../lib/libwebsockets-2.4.0/lib \
-L../lib/libbinacpp/lib \
-lcurl  -lcrypto -lwebsockets -lbinacpp -o example
/tmp/ccCycCcN.o: In function `ws_depth_onData(Json::Value&)':
example.cpp:(.text+0xd85): undefined reference to `Json::Value::asString[abi:cxx11]() const'
example.cpp:(.text+0xdf0): undefined reference to `Json::Value::asString[abi:cxx11]() const'
example.cpp:(.text+0xf79): undefined reference to `Json::Value::asString[abi:cxx11]() const'
example.cpp:(.text+0xfe4): undefined reference to `Json::Value::asString[abi:cxx11]() const'
/tmp/ccCycCcN.o: In function `ws_klines_onData(Json::Value&)':
example.cpp:(.text+0x1255): undefined reference to `Json::Value::asString[abi:cxx11]() const'
/tmp/ccCycCcN.o:example.cpp:(.text+0x1317): more undefined references to `Json::Value::asString[abi:cxx11]() const' follow
/tmp/ccCycCcN.o: In function `main':
example.cpp:(.text+0x22c4): undefined reference to `BinaCPP::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
example.cpp:(.text+0x242d): undefined reference to `Json::Value::asString[abi:cxx11]() const'
example.cpp:(.text+0x24aa): undefined reference to `Json::Value::asString[abi:cxx11]() const'
example.cpp:(.text+0x25e5): undefined reference to `Json::Value::asString[abi:cxx11]() const'
example.cpp:(.text+0x2659): undefined reference to `Json::Value::asString[abi:cxx11]() const'
example.cpp:(.text+0x27d2): undefined reference to `Json::Value::asString[abi:cxx11]() const'
/tmp/ccCycCcN.o:example.cpp:(.text+0x28a2): more undefined references to `Json::Value::asString[abi:cxx11]() const' follow
collect2: error: ld returned 1 exit status
Makefile:25: recipe for target 'example' failed
make: *** [example] Error 1

I looked this error up and I'm guessing this is a linker error like described in this post. However I'm coming from Python and new to C++ and just don't see what is wrong. I see that the .h files are included and in

 binacpp_websocket.h

I see

 typedef int (*CB)(Json::Value &json_value );

Why am I getting the error?

NOTE: When trying to run the command "make example" I got the error:

Making example


g++ -I../lib/libcurl-7.56.0/include -I../lib/jsoncpp-1.8.3/include -I../lib/libwebsockets-2.4.0/include -I../lib/libbinacpp/include \
example.cpp \
-L../lib/libcurl-7.56.0/lib \
-L../lib/libwebsockets-2.4.0/lib \
-L../lib/libbinacpp/lib \
-lcurl -ljsoncpp -lcrypto -lwebsockets -lbinacpp -o example
/usr/bin/ld: cannot find -ljsoncpp
collect2: error: ld returned 1 exit status
Makefile:25: recipe for target 'example' failed
make: *** [example] Error 1

Somewhere in the repo (I cannot find it now) it said that "-ljsoncpp" shouldn't be there. After removing this the compiler did run but it gave the linker error.

user3605780
  • 6,542
  • 13
  • 42
  • 67
  • Did you compile `jsoncpp` library? – user7860670 Apr 22 '18 at 17:26
  • @VTT , it only said I needed to run, "make example". in the folder /lib/libbinacpp/lib I see jsoncpp.o. In the folder that is included in the make file /lib/jsoncpp-1.8.3 I only see the include folder with the header files and the src folder with the cpp file. – user3605780 Apr 22 '18 at 17:33
  • This is the make file https://github.com/tensaix2j/binacpp/blob/master/example/Makefile However in the description on the main page it doesn't show the -ljsoncpp – user3605780 Apr 22 '18 at 17:36
  • It seem that `jsoncpp.cpp` is compiled statically as part of `binacpp` for some reason. – user7860670 Apr 22 '18 at 18:14
  • @VTT Is that the reason why the creator said it doesn't need to be in the make file? – user3605780 Apr 22 '18 at 19:03

0 Answers0