一, 简介
LSQUIC(LiteSpeed QUIC) 是一个 QUIC 和 HTTP3 功能的开源实现, 它是用 c 写的,提供 library ,client 和 server3 种方式, 而且它支持多种平台(Linux,ios ,android,Windows),而且文档非常完善. 本文主要讲如何在 linux 环境下编译 lsquic.
二, 环境
编译 lsquic 需要 CMake, zlib, ,BoringSSL 以及 libevent ,libevent 是其底层依赖的网络库.
三, 编译
1, boringssl 编译
git clone https://boringssl.googlesource.com/boringssl
lsquic 依赖固定版本的 boringssl
git checkout a2278d4d2cabe73f6663e3299ea7808edfa306b9
boringssl 依赖 golang, 所以需要先安装 golang
yum install -y golang
mkdir build && cd build && cmake ../ && make && cd ../
此时, include 和 libs 都已经编译完成, 由于 libcrypto.a 和 libssl.a 不在同一目录,我们需要把他们放到一起,便于后期编译 lsquic .
2, lsquic 编译
git clone https://github.com/litespeedtech/lsquic.git
cd lsquic
git submodule init
git submodule update
复制代码
cmake -DBORINGSSL_INCLUDE=/home/code/boringssl/include -DBORINGSSL_LIB=/home/code/boringssl/openssl/libs .
复制代码
make
make test
四, 编译问题及解决方法
编译的时候遇到几个编译错误, 记录如下:
1,boringssl 编译问题
[ 0%] Generating crypto_test_data.cc
go: golang.org/x/crypto@v0.0.0-20200622213623-75b288015ac9: Get "https://proxy.golang.org/golang.org/x/crypto/@v/v0.0.0-20200622213623-75b288015ac9.mod": dial tcp 142.251.43.17:443: i/o timeout
make[2]: *** [CMakeFiles/crypto_test_data.dir/build.make:226: crypto_test_data.cc] Error 1
make[2]: *** Deleting file 'crypto_test_data.cc'
make[1]: *** [CMakeFiles/Makefile2:134: CMakeFiles/crypto_test_data.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
复制代码
go env -w GOPROXY=https://goproxy.cn
复制代码
2,lsquic 编译问题
[root@localhost lsquic]# cmake -DBORINGSSL_INCLUDE=/home/code/boringssl/include -DBORINGSSL_LIB=/home/code/boringssl/openssl/libs .
-- Build type: Debug
-- AddressSanitizer is OFF
-- Compiler flags: -DLSQUIC_DEBUG_NEXT_ADV_TICK=1 -DLSQUIC_CONN_STATS=1 -Wall -Wextra -Wno-unused-parameter -fno-omit-frame-pointer -Wno-missing-field-initializers -O0 -g3
-- BoringSSL include directory /home/code/boringssl/include
-- Found /home/code/boringssl/openssl/libs library: /home/code/boringssl/openssl/libs/libssl.a
-- Found /home/code/boringssl/openssl/libs library: /home/code/boringssl/openssl/libs/libcrypto.a
-- /home/code/boringssl/openssl/libs library not found
-- zlib not found
-- Found event: /usr/lib64/libevent.so
-- sphinx-build not found: docs won't be made
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
复制代码
通过手动编译 zlib,就可以了
git clone https://github.com/madler/zlib
./configure
make&&make install
复制代码
评论