linux 编译c++ socket.io

下载socket.io客户端

git clone https://github.com/socketio/socket.io-client-cpp.git

打开文件夹

cd socket.io-client-cpp/lib

可以看到它依赖的外部库,这四个文件夹都是空的,删除他们,自己下载相对应的库放在这个目录下,并不需要编译它们。

git clone https://github.com/Tencent/rapidjson.git
git clone https://github.com/zaphoyd/websocketpp.git
https://github.com/chriskohlhoff/asio/releases
https://github.com/catchorg/Catch2/releases

同时它运行时还依赖boost,需要编译boost库。

https://sourceforge.net/projects/boost/files/boost/

运行./bootstrap.sh,作编译前的配置,下面配置以下生成库存放的路径。

sudo ./bootstrap.sh --prefix=/home/yqw/temp/socket.io-client-cpp/lib/boost_1_80_0/output

开始编译安装

sudo ./b2 install

开始编译socket.io客户端了

cd socket.io-client-cpp
mkdir build

可以看到这里配置了boost库的路径和版本。

cmake .. -DBOOST_ROOT:STRING=/home/yqw/temp/socket.io-client-cpp/lib/boost_1_80_0/output -DBOOST_VER:STRING=1.80.0
make -j20
sudo make install

参考:
对socket.io的使用参考官网:
https://socket.io/blog/socket-io-cpp/
对socket.io的使用使用参考:
https://blog.csdn.net/xiaopei_yan/article/details/125259645
C++之socket.io编译使用
这里是客户端,服务器源码:
https://github.com/socketio/socket.io/tree/master/examples/chat
运行起来后,可以用几个浏览器界面打开:http://localhost:3000进行通信,或使用c++客户端。
websocket和socket.io的区别:
https://zhuanlan.zhihu.com/p/346650330

编译socket.io
关于socket.io的四个依赖库,为了防止依赖库更新导致编译问题,尽量使用发行版:
socket.io-client-cpp与boost的编译、交叉编译
关于boost的卸载参考:boost卸载

猜你喜欢

转载自blog.csdn.net/weixin_43466192/article/details/126617027