the right way to compile and use this project
-
Update all of the submodule, the current version of submodule has some bug.
cd lib/rapidjson git pull origin master cd ../.. cd lib/websocketpp git pull origin master -
Compile
boost 1.67.0# build debug ./b2 debug cflags=-fPIC --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi #build release ./b2 cflags=-fPIC --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi -
Compile
OpenSSL 1.0.2uJust follow the
INSTALLfile. What you need to know is that you should use./config -fPIC -
build this project I change the
CMakeLists.txt, just addset(CMAKE_POSITION_INDEPENDENT_CODE ON)# build release cmake -DCMAKE_CXX_FLAGS=-std=c++11 -DOPENSSL_ROOT_DIR:STRING=/usr/local/ssl -DOPENSSL_VERSION:STRING=1.0.1 -DBOOST_INCLUDEDIR=~/boost_1_67_0 -DBOOST_LIBRARYDIR=~/boost_1_67_0/stage/lib -DBOOST_VER:STRING=1.67.0 ./ make install make clean #build debug cmake -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_BUILD_TYPE=Debug -DOPENSSL_ROOT_DIR:STRING=/usr/local/ssl -DOPENSSL_VERSION:STRING=1.0.1 -DBOOST_INCLUDEDIR=~/boost_1_67_0 -DBOOST_LIBRARYDIR=~/boost_1_67_0/stage/lib -DBOOST_VER:STRING=1.67.0 ./ make install make clean -
the Qt pri file should write like this
HEADERS += \ $$PWD/include/sio_client.h \ $$PWD/include/sio_message.h \ $$PWD/include/sio_socket.h INCLUDEPATH += $$PWD/include CONFIG(debug, debug|release) { LIBS += -L$$PWD/lib/linux/Debug LIBS += -lsioclient } else { DEFINES += SIO_TLS LIBS += -L$$PWD/lib/linux/Release LIBS += -lsioclient_tls -ldl -lssl -lcrypto } LIBS += -lboost_system -lboost_random -lboost_date_time
What you need to know is that, in release mode , you only can https/wss and you only can use http/ws in Debug mode
I didn't use the no_keywords flag, because my project has lots of submoudle, I don't want to change them. You can Use this way to using socket.io within a Qt environment.
#undef emit
#include "sio_client.h"
#define emit
sio::client web_socket;
#undef emit
web_socket.socket()->emit(kEventname, message_list);
#define emit
I have try boost 1.73.0 and OpenSSL 1.1.1g, all is well.
Are you testing this over http:// or https:// connections? I see that most examples point to a http://localhost? Just curious if have been able to use SSL for the socket connection historically?
@NateShaq Yeap. If you write the pri file like I wrote before, you can use SSL in Release mode.