windows环境下配置libwebsocket

1. 下载cmake:

下载链接:

https://cmake.org/download/

安装版本:

cmake-3.21.0-windows-x86_64.msi

2.下载openssl:

下载链接:

https://slproweb.com/products/Win32OpenSSL.html

安装版本:

Win64 OpenSSL v1.1.1k Light MSI

其他老版本下载:

https://www.openssl.org/source/old/

3. 安装cmake和openssl

4.下载libwebsocket源代码

https://github.com/warmcat/libwebsockets/

示例详解:

https://libwebsockets.org/git/libwebsockets/tree/minimal-examples

5.代码解压编译

libwebsocket代码放在桌面

C:\Users\ASUS\Desktop\libwebsocket\libwebsockets-main\libwebsockets-main

cd进去代码根目录

mkdir build   创建编译目录

cd build

编译,需配置openssl的编译环境:

cmake .. -DLIB_SUFFIX=32 -DLWS_HTTP2=1 -DLWS_OPENSSL_INCLUDE_DIRS=S:\OpenSSL-Win64\include\openssl -DLWS_OPENSSL_LIBRARIES=S:\OpenSSL-Win64\lib

编译结果:

C:\Users\ASUS\Desktop\libwebsocket\libwebsockets-main\libwebsockets-main\build>cmake .. -DLIB_SUFFIX=32 -DLWS_HTTP2=1 -DLWS_OPENSSL_INCLUDE_DIRS=S:\OpenSSL-Win64\include\openssl -DLWS_OPENSSL_LIBRARIES=S:\OpenSSL-Win64\lib
-- Compiled with LWS_WITH_DIR and LWS_WITH_LEJP_CONF
SMD requires pthreads
-- Could NOT find Git (missing: GIT_EXECUTABLE)
No afunix.h found. Disabling LWS_UNIX_SOCK.
Compiling with SSL support
OpenSSL include dir: S:/OpenSSL-Win64/include/openssl
OpenSSL libraries: S:/OpenSSL-Win64/lib
Searching for OpenSSL executable and dlls
OpenSSL executable: OPENSSL_EXECUTABLE-NOTFOUND
 GENCERTS = 0
DIR C:/Users/ASUS/Desktop/libwebsocket/libwebsockets-main/libwebsockets-main CMP C:/Users/ASUS/Desktop/libwebsocket/libwebsockets-main/libwebsockets-main/cmake
-- Configuring done
WARNING: Target "websockets" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "websockets" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "websockets" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "websockets" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "websockets_shared" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "websockets_shared" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "websockets_shared" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "websockets_shared" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-server" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-server" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-server" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-server" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-lejp" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-lejp" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-lejp" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-lejp" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-client" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-client" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-client" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "test-client" requests linking to directory "S:/OpenSSL-Win64/lib".  Targets may link only to libraries.  CMake is dropping the item.
-- Generating done
-- Build files have been written to: C:/Users/ASUS/Desktop/libwebsocket/libwebsockets-main/libwebsockets-main

根目录生成了sln工程文件,可以用vs打开了,编译完成。

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值