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打开了,编译完成。

windows环境下配置libwebsocket_第1张图片

你可能感兴趣的:(libwebsocket)