BUILD-WINDOWS.md revision 9711bfba
1eef4f2fcSDmitri TikhonovLiteSpeed QUIC (LSQUIC) Client Library - Building for Windows 2eef4f2fcSDmitri Tikhonov============================================================= 3eef4f2fcSDmitri Tikhonov 4eef4f2fcSDmitri TikhonovDescription 5eef4f2fcSDmitri Tikhonov----------- 6eef4f2fcSDmitri Tikhonov 7eef4f2fcSDmitri TikhonovThis document is intended to supplement the document README.md at the 8eef4f2fcSDmitri Tikhonovroot of the distribution of the LiteSpeed QUIC (LSQUIC) Client Library 9eef4f2fcSDmitri Tikhonovto build the library and programs in a Windows environment. 10eef4f2fcSDmitri Tikhonov 11eef4f2fcSDmitri TikhonovThe addition of Windows support to the LSQUIC Client was a contribution 12eef4f2fcSDmitri Tikhonovfrom the user community and this document was based on our experiences 13eef4f2fcSDmitri Tikhonovof validating the code. As for the overall implementation, do not hesitate 14eef4f2fcSDmitri Tikhonovto report bugs back to us. Even better, continue to send us fixes and 15eef4f2fcSDmitri Tikhonovimprovements - it makes the code better for everyone. 16eef4f2fcSDmitri Tikhonov 17eef4f2fcSDmitri Tikhonov 18eef4f2fcSDmitri TikhonovPreliminaries 19eef4f2fcSDmitri Tikhonov------------- 20eef4f2fcSDmitri TikhonovIt it recommended that the installer have experience with Windows development, 21eef4f2fcSDmitri TikhonovVisual Studio, and open source projects in Windows. These instructions assume 22eef4f2fcSDmitri Tikhonova general build, primarily for 64-bit, both of a debug and a release version. 23eef4f2fcSDmitri Tikhonov 24eef4f2fcSDmitri TikhonovSome open source code required to be installed to build the code include: 25eef4f2fcSDmitri Tikhonov - The [Git version control system executable for Windows](https://git-scm.com/download/win). 26eef4f2fcSDmitri Tikhonov - A version of the Visual Studio development environment for Windows. 27eef4f2fcSDmitri Tikhonov The Windows SDK and C++ must be installed from it. The 28eef4f2fcSDmitri Tikhonov [Visual Studio Community Edition](https://www.visualstudio.com/thank-you-downloading-visual-studio) will be just fine. 29eef4f2fcSDmitri Tikhonov - [cmake for Windows](https://cmake.org/download/). Download and install the 30eef4f2fcSDmitri Tikhonov version appropriate for the development/target platform (32 vs 64-bits, 31eef4f2fcSDmitri Tikhonov etc.). 32eef4f2fcSDmitri Tikhonov - The Windows vcpkg package manager. It can be cloned from [here](https://github.com/Microsoft/vcpkg). 33eef4f2fcSDmitri Tikhonov Clone it at the same level to be used to clone/develop the lsquic-client. 34eef4f2fcSDmitri Tikhonov The package must be compiled following the instructions on the git 359711bfbaSLiteSpeed Tech repository. 369711bfbaSLiteSpeed Tech - Perform builds using the _Developer Command Prompt for Visual Studio_ instead 379711bfbaSLiteSpeed Tech of the regular `cmd.exe`. 38eef4f2fcSDmitri Tikhonov - Once the package manager has been built, it must be used to install 39eef4f2fcSDmitri Tikhonov and build some open source projects. Before doing that, an environment 40eef4f2fcSDmitri Tikhonov variable must be defined which specifies how the package should be built. 41eef4f2fcSDmitri Tikhonov The easiest way would be to add it into the system environment variables 42eef4f2fcSDmitri Tikhonov in the System applet of the Windows Control Panel. This example assumes 43eef4f2fcSDmitri Tikhonov 64-bit static libraries will be built, which is what is generally 44eef4f2fcSDmitri Tikhonov recommended: 45eef4f2fcSDmitri Tikhonov ``` 46eef4f2fcSDmitri Tikhonov VCPKG_DEFAULT_TRIPLET=x64-windows-static 47eef4f2fcSDmitri Tikhonov ``` 48eef4f2fcSDmitri Tikhonov - From the command line, once the variable above has been defined, install 49eef4f2fcSDmitri Tikhonov both *zlib* and *libevent*. Note that libevent may also automatically 50eef4f2fcSDmitri Tikhonov install *openssl*. If it does not, it may need to be manually specified 51eef4f2fcSDmitri Tikhonov to properly link the lsquic-client executables. 52eef4f2fcSDmitri Tikhonov ``` 539711bfbaSLiteSpeed Tech vcpkg install zlib:x86-windows-static 549711bfbaSLiteSpeed Tech vcpkg install libevent:x64-windows-static 559711bfbaSLiteSpeed Tech vcpkg integrate install 56eef4f2fcSDmitri Tikhonov ``` 579711bfbaSLiteSpeed Tech - Clone and compile boringssl. It can be cloned from [here](https://boringssl.googlesource.com/boringssl). 589711bfbaSLiteSpeed Tech 59eef4f2fcSDmitri Tikhonov ``` 609711bfbaSLiteSpeed Tech git clone https://boringssl.googlesource.com/boringssl 619711bfbaSLiteSpeed Tech cd boringssl 62eef4f2fcSDmitri Tikhonov cmake -DCMAKE_GENERATOR_PLATFORM=x64 --config Debug -DBUILD_SHARED_LIBS=OFF -DOPENSSL_NO_ASM=1 . 639711bfbaSLiteSpeed Tech msbuild ALL_BUILD.vcxproj 649711bfbaSLiteSpeed Tech set boringssl=%cd% 65eef4f2fcSDmitri Tikhonov ``` 66eef4f2fcSDmitri Tikhonov - Visual Studio can be run, and the project opened within the boringssl 67eef4f2fcSDmitri Tikhonov directory. Set the solution configuration to *Debug* and the solution 68eef4f2fcSDmitri Tikhonov platform to *64-bit*. Compile the project. 69eef4f2fcSDmitri Tikhonov - Repeat the cmake and compile steps replacing *Debug* with *Release*. 70eef4f2fcSDmitri Tikhonov 71eef4f2fcSDmitri TikhonovMake and Compile LSQUIC-Client 72eef4f2fcSDmitri Tikhonov------------------------------ 73eef4f2fcSDmitri Tikhonov 749711bfbaSLiteSpeed Tech 759711bfbaSLiteSpeed TechClone lsquic-client: 769711bfbaSLiteSpeed Tech 77eef4f2fcSDmitri Tikhonov ``` 78eef4f2fcSDmitri Tikhonov git clone https://github.com/litespeedtech/lsquic-client.git 79eef4f2fcSDmitri Tikhonov cd lsquic-client 80eef4f2fcSDmitri Tikhonov ``` 81eef4f2fcSDmitri Tikhonov 829711bfbaSLiteSpeed TechConfigure the build using cmake (you can specify `Release` instead of `Debug` 839711bfbaSLiteSpeed Techto build an optimized version of the library, but that won't build tests): 849711bfbaSLiteSpeed Tech 85eef4f2fcSDmitri Tikhonov ``` 869711bfbaSLiteSpeed Tech cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DBUILD_SHARED_LIBS=OFF ^ 879711bfbaSLiteSpeed Tech -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_BUILD_TYPE=Debug ^ 889711bfbaSLiteSpeed Tech -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake ^ 899711bfbaSLiteSpeed Tech -DBORINGSSL_DIR=%boringssl% . 90eef4f2fcSDmitri Tikhonov ``` 91eef4f2fcSDmitri Tikhonov 929711bfbaSLiteSpeed TechCompile everything (add `/m` flag if you have processors to spare): 93eef4f2fcSDmitri Tikhonov 94eef4f2fcSDmitri Tikhonov ``` 959711bfbaSLiteSpeed Tech msbuild ALL_BUILD.vcxproj 96eef4f2fcSDmitri Tikhonov ``` 97eef4f2fcSDmitri Tikhonov 989711bfbaSLiteSpeed Tech`http_client.exe` should be found in the `Debug` (or `Release`) directory. 999711bfbaSLiteSpeed Tech 1009711bfbaSLiteSpeed TechRun tests (assuming `Debug` build): 1019711bfbaSLiteSpeed Tech 1029711bfbaSLiteSpeed Tech ``` 1039711bfbaSLiteSpeed Tech msbuild RUN_TESTS.vcxproj 1049711bfbaSLiteSpeed Tech ``` 105eef4f2fcSDmitri Tikhonov 106eef4f2fcSDmitri TikhonovHave fun, 107eef4f2fcSDmitri Tikhonov 108eef4f2fcSDmitri TikhonovLiteSpeed QUIC Team. 109eef4f2fcSDmitri Tikhonov 1109711bfbaSLiteSpeed TechCopyright (c) 2017 - 2019 LiteSpeed Technologies Inc 111