- 下載cmake:
下載鏈接:
安裝版本:
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/
- 安裝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打開了,編譯完成。