binance-exchange / binacpp

Binance C++ library
MIT License
209 stars 108 forks source link

LCCSCF_USE_SSL was not defined in this scope #24

Open AlconDivino opened 6 years ago

AlconDivino commented 6 years ago

Pretty much the title. I got rasbian on raspberry pi. i installed libcurl4-openssl-dev and libwebsockets-dev with the apt-get command.

now i included the libraries and header into the makefile looking like this:

libcurl_dir=../lib/libcurl-7.56.0
libcurl_include=/usr/include/arm-linux-gnueabihf
libcurl_lib=/usr/lib/arm-linux-gnueabihf/

jsoncpp_dir=../lib/jsoncpp-1.8.3
jsoncpp_include=${jsoncpp_dir}/include
jsoncpp_src=${jsoncpp_dir}/src
libwebsockets_dir=../lib/libwebsockets-2.4.0
libwebsockets_include=/usr/include/
libwebsockets_lib=/usr/lib/arm-linux-gnueabihf/libwebsockets.so

build_dir=../lib/libbinacpp/lib
objects=$(build_dir)/jsoncpp.o $(build_dir)/binacpp_utils.o $(build_dir)/binacpp_logger.o $(build_dir)/binacpp.o  $(build_dir)/binacpp_websocket.o

build_include=../lib/libbinacpp/include

$(build_dir)/libbinacpp.so: $(objects)
    g++ -I$(libcurl_include) -I$(jsoncpp_include) -I$(libwebsockets_include)  \
    -L$(libcurl_lib) \
    -L$(libwebsockets_lib) \
    $(objects) \
    -shared \
    -lcurl -lcrypto -lwebsockets -fPIC -o $@

    # Make a new copy of the header too
    cp *.h  $(build_include)

$(build_dir)/binacpp.o: binacpp.cpp binacpp.h 
    g++ -I$(libcurl_include) -I$(jsoncpp_include) -c binacpp.cpp  -fPIC   -o $(build_dir)/binacpp.o 

$(build_dir)/binacpp_websocket.o: binacpp_websocket.cpp binacpp_websocket.h 
    g++ -I$(libwebsockets_include) -I$(jsoncpp_include) -c binacpp_websocket.cpp  -fPIC   -o $(build_dir)/binacpp_websocket.o

$(build_dir)/binacpp_logger.o: binacpp_logger.cpp binacpp_logger.h 
    g++ -c binacpp_logger.cpp  -fPIC   -o $(build_dir)/binacpp_logger.o 

$(build_dir)/binacpp_utils.o: binacpp_utils.cpp binacpp_utils.h 
    g++ -c binacpp_utils.cpp -fPIC   -o $(build_dir)/binacpp_utils.o 

$(build_dir)/jsoncpp.o: $(jsoncpp_src)/jsoncpp.cpp
    g++ -I$(jsoncpp_include) -c $(jsoncpp_src)/jsoncpp.cpp -fPIC  -o  $(build_dir)/jsoncpp.o

clean:
    rm $(build_dir)/*.o
    rm $(build_dir)/*.so

Now i Try to run make in the directory and now i get the following errors with a lot of warnings but lets leave that aside:`

g++ -c binacpp_utils.cpp -fPIC   -o ../lib/libbinacpp/lib/binacpp_utils.o 
g++ -c binacpp_logger.cpp  -fPIC   -o ../lib/libbinacpp/lib/binacpp_logger.o 
g++ -I/usr/include/arm-linux-gnueabihf -I../lib/jsoncpp-1.8.3/include -c binacpp.cpp  -fPIC   -o ../lib/libbinacpp/lib/binacpp.o 
g++ -I/usr/include/ -I../lib/jsoncpp-1.8.3/include -c binacpp_websocket.cpp  -fPIC   -o ../lib/libbinacpp/lib/binacpp_websocket.o
binacpp_websocket.cpp: In static member function ‘static void BinaCPP_websocket::connect_endpoint(CB, const char*)’:
binacpp_websocket.cpp:116:26: error: ‘LCCSCF_USE_SSL’ was not declared in this scope
  ccinfo.ssl_connection = LCCSCF_USE_SSL | LCCSCF_ALLOW_SELFSIGNED | LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK;
                          ^~~~~~~~~~~~~~
binacpp_websocket.cpp:116:43: error: ‘LCCSCF_ALLOW_SELFSIGNED’ was not declared in this scope
  ccinfo.ssl_connection = LCCSCF_USE_SSL | LCCSCF_ALLOW_SELFSIGNED | LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK;
                                           ^~~~~~~~~~~~~~~~~~~~~~~
binacpp_websocket.cpp:116:69: error: ‘LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK’ was not declared in this scope
  ccinfo.ssl_connection = LCCSCF_USE_SSL | LCCSCF_ALLOW_SELFSIGNED | LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK;
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Makefile:42: recipe for target '../lib/libbinacpp/lib/binacpp_websocket.o' failed
make: *** [../lib/libbinacpp/lib/binacpp_websocket.o] Error 1

Any ideas what could be the cause?

alexanderkoumis commented 6 years ago

Hi I am going to try to walk you through the mental steps you should follow to debug C++ builds because it seems like you are pretty new to this.

What does the message <some_variable> was not declared in this scope tell you? This is the kind of error message you would get if your entire program was like this:

#include <cstdio>
int main(int argc, char** argv) {
  printf("%f\n", some_variable);
  return 0;
}

some_variable was never defined. When encountering a message like this when building someone else's library (that other people have built successfully) from source, it is safe to assume that the author did not make a mistake and forget to define a variable and this variable is likely defined in a third party library the author is using.

The first result of googling LCCSCF_USE_SSL tells us this variable is from libwebsockets. Looking back at how you modified the makefile, you set libwebsockets_include to /usr/include/. So your mistake is that wherever libwebsockets installed it's include files to is not visible from /usr/include/.

AlconDivino commented 6 years ago

i updated the libwebsocketspackage and now i compiled everything and i can work with it.

Yes i'm pretty new and thanks for the advice.

Now i'm gonna see how that whole json thing works and I'llbe fine