Libwebsockets库的构建
- 若未安装CMake,则先进行CMake的安装
安装CMake安装如下步骤进行:
- wget https://cmake.org/files/v3.3/cmake-3.3.2.tar.gz
- # tar xzvf cmake-3.3.2.tar.gz
- # ./bootstrap
- # make
- # make install
#mkdir build
#cd build
#cmake ..
#make
#提供libcrypto.so libssl.so
编译成功后:将build下的share/libwebsockets-test-server文件夹拷贝到/usr/local/share/路径下,然后执行服务器:./bin/libwebsockets-test-server
[2019/11/22 13:53:46:5011] N: libwebsockets test server - license LGPL2.1+SLE
[2019/11/22 13:53:46:5012] N: (C) Copyright 2010-2018 Andy Green <andy@warmcat.com>
Using resource path "/usr/local/share/libwebsockets-test-server"
在浏览器上输入http://192.168.227.241:7681/即可访问示例版的websocket的服务器。
- 使用交叉编译器arm-linux-gnueabihf-gcc编译libsockets库:
cmake .. \
-DCMAKE_INSTALL_PREFIX=/usr/local/libwebsockets-master/myout \
-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
-DLWS_OPENSSL_LIBRARIES="/usr/local/gcc-linaro-arm-linux-gnueabihf-4.9-zmm720-64/arm-linux-gnueabihf/lib/libssl.so;/usr/local/gcc-linaro-arm-linux-gnueabihf-4.9-zmm720-64/arm-linux-gnueabihf/lib/libcrypto.so"