LSQUIC Build Issue
Problem
When building the LSQUIC project, users encountered linking errors related to C++ symbols from BoringSSL. The main issues were:
- The project was configured to use only C, but BoringSSL requires C++ support.
- The linker couldn't find certain C++ symbols, indicating a mismatch between the BoringSSL library and the LSQUIC project settings.
Solution
The solution involved several steps to properly integrate BoringSSL with LSQUIC:
-
Modified the CMakeLists.txt to include C++ support:
- Changed
PROJECT(lsquic C)toPROJECT(lsquic C CXX)
- Changed
-
Added the C++ standard library to the linker flags:
- Modified the LIBS variable in CMakeLists.txt to include
-lstdc++
- Modified the LIBS variable in CMakeLists.txt to include
-
Ensured correct paths to BoringSSL were provided to CMake:
cmake -DBORINGSSL_DIR=/path/to/boringssl \ -DBORINGSSL_INCLUDE=/path/to/boringssl/include \ -DBORINGSSL_LIB_ssl=/path/to/boringssl/build/ssl/libssl.a \ -DBORINGSSL_LIB_crypto=/path/toboringssl/build/crypto/libcrypto.a \ .. -
If necessary, rebuilt BoringSSL with compatible compiler settings:
cd /path/to/boringssl rm -rf build mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. make
Steps to Build LSQUIC
- Ensure BoringSSL is properly built and its path is known.
- Clean the LSQUIC build directory:
cd /path/to/lsquic/build rm -rf * - Run CMake with the correct BoringSSL paths:
cmake -DBORINGSSL_DIR=/path/to/boringssl \ -DBORINGSSL_INCLUDE=/path/to/boringssl/include \ -DBORINGSSL_LIB_ssl=/path/to/boringssl/build/ssl/libssl.a \ -DBORINGSSL_LIB_crypto=/path/to/boringssl/build/crypto/libcrypto.a \ .. - Build the project:
make
This needs merging. The BORINGSSL env var is a bad way to provide the locations of boringssl since the include dir remains with the source and the libraries are in different paths. Providing them seperately like this is a far better way IMO. Also adding the CXX to the project type and adding stdc++ on line 272 of CMakeLists.txt SET(LIBS lsquic ${BORINGSSL_LIB_ssl} ${BORINGSSL_LIB_crypto} ${ZLIB_LIB} ${LIBS} stdc++) got rid of the errors when linking to boringssl.
Right now you need to use:
Cleanup:
rm -rf boringssl lsquic
Build boringssl:
git clone https://boringssl.googlesource.com/boringssl
mkdir boringssl/build
cd boringssl/build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j
cd ..
set -g -x BORINGSSL $PWD
cd ..
Build lsquic:
git clone https://github.com/litespeedtech/lsquic.git
cd lsquic
git submodule update --init
mkdir build
cd build
cmake -DBORINGSSL_DIR=$BORINGSSL \
-DBORINGSSL_INCLUDE=$BORINGSSL/include \
-DBORINGSSL_LIB_ssl=$BORINGSSL/build/libssl.a \
-DBORINGSSL_LIB_crypto=$BORINGSSL/build/libcrypto.a \
..
make -j
P.S. I use set -g -x BORINGSSL $PWD for fish, if you're using bash, please replace this line with BORINGSSL=$PWD.
Since the time this issue was opened, the build mechanism has undergone significant changes (hopefully, improvements). @mhmdreda99, could you please give this another shot and report whether the issues that were hindering you have been resolved?