Skip to content

Commit 6fccaa2

Browse files
niedbalskiJorge Niedbalski
and
Jorge Niedbalski
authored
docs: DEVELOPER_GUIDE: add instructions for windows 2022 (#9522)
* Adds Windows 2022 setup instructions. step-by-step for setting up the environment to build Fluent Bit on Windows Server 2022, including Visual Studio installation, Flex and Bison setup, and dependency management using vcpkg. * Corrected references from Chocolatey to vcpkg for dependency installation, aligning the local build guide with the tools used in CI. Signed-off-by: Jorge Niedbalski <[email protected]> Co-authored-by: Jorge Niedbalski <[email protected]>
1 parent cf85f89 commit 6fccaa2

File tree

1 file changed

+130
-1
lines changed

1 file changed

+130
-1
lines changed

DEVELOPER_GUIDE.md

+130-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,8 @@ The dependencies must be present:
711711

712712
* Microsoft Visual Studio C/C++ toolchain. The CI automation uses MSVC 2019 at time of writing. MSVC Community Edition works fine.
713713
* [CMake](https://cmake.org/) 3.x on the `PATH`
714-
* A build of [OpenSSL](https://www.openssl.org/) as static libraries, pointed to by the `-DOPENSSL_ROOT_DIR` CMake variable. The CI automation uses [Chocolatey](https://chocolatey.org/) to `choco install -y openssl`.
714+
* A build of [OpenSSL](https://www.openssl.org/) as static libraries, pointed to by the `-DOPENSSL_ROOT_DIR` CMake variable.
715+
* The CI automation uses vcpkg to install dependencies [](https://github.com/fluent/fluent-bit/blob/master/.github/workflows/call-build-windows.yaml#L148)
715716
* `flex.exe` and `bison.exe` must be present on the `PATH`. The CI automation uses https://github.com/lexxmark/winflexbison.
716717

717718
Assuming that `cmake` is on the `PATH`, Visual Studio is installed,
@@ -731,6 +732,134 @@ The build output will be `bin\Debug\fluent-bit.exe`.
731732

732733
If in doubt, check the CI and build automation files referenced above for specifics.
733734

735+
### Building on a Windows Server 2022
736+
737+
The following steps have been tested on a Windows Server 2022 Datacenter edition on top of GCP.
738+
739+
1. **Download and Install Visual Studio 2022** (Community Edition)
740+
- **Download**: Go to [Visual Studio Download Page](https://visualstudio.microsoft.com/downloads/).
741+
- **Install**:
742+
- Select **Community Edition** and check the following components during installation:
743+
- **Desktop development with C++**
744+
- **Linux development with C++**
745+
746+
2. **Install Flex and Bison**
747+
1. Create a new file called `setup-flex-bison.ps1` and paste the following script:
748+
749+
```powershell
750+
# Define variables for Flex and Bison
751+
$flexBisonUrl = "https://sourceforge.net/projects/winflexbison/files/win_flex_bison3-latest.zip/download"
752+
$downloadPath = "$env:TEMP\win_flex_bison.zip"
753+
$extractPath = "C:\win_flex_bison"
754+
$flexExe = "flex.exe"
755+
$bisonExe = "bison.exe"
756+
757+
# Step 2: Download and Setup Flex and Bison
758+
Write-Output "Downloading win_flex_bison..."
759+
Invoke-WebRequest -Uri $flexBisonUrl -OutFile $downloadPath
760+
761+
# Create the extract directory if it does not exist
762+
If (!(Test-Path -Path $extractPath)) {
763+
New-Item -ItemType Directory -Path $extractPath
764+
}
765+
766+
# Extract the zip file
767+
Write-Output "Extracting win_flex_bison..."
768+
Add-Type -AssemblyName System.IO.Compression.FileSystem
769+
[System.IO.Compression.ZipFile]::ExtractToDirectory($downloadPath, $extractPath)
770+
771+
# Rename the executables
772+
Write-Output "Renaming executables..."
773+
Rename-Item "$extractPath\win_flex.exe" "$extractPath\$flexExe" -Force
774+
Rename-Item "$extractPath\win_bison.exe" "$extractPath\$bisonExe" -Force
775+
776+
# Add Flex and Bison path to system environment variables
777+
Write-Output "Adding Flex and Bison path to environment variables..."
778+
$envPath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
779+
If ($envPath -notlike "*$extractPath*") {
780+
[System.Environment]::SetEnvironmentVariable("Path", "$envPath;$extractPath", "Machine")
781+
Write-Output "Path updated. Please restart your command prompt to apply changes."
782+
} else {
783+
Write-Output "Path already contains the Flex and Bison directory."
784+
}
785+
786+
# Cleanup
787+
Remove-Item $downloadPath
788+
789+
Write-Output "Flex and Bison setup complete."
790+
```
791+
792+
2. Run the Script: Open PowerShell as administrator.
793+
794+
```powershell
795+
.\setup-flex-bison.ps1
796+
```
797+
798+
3. Restart the command prompt: After the script completes, restart your command prompt or Visual Studio for the changes to take effect.
799+
800+
3. **Create `vcpkg.json` file for the dependencies**
801+
802+
In the root of your project, create a `vcpkg.json` file with the following content:
803+
804+
```json
805+
{
806+
"name": "fluent-bit",
807+
"version": "3.2.0",
808+
"dependencies": [
809+
{
810+
"name": "openssl",
811+
"default-features": false
812+
},
813+
{
814+
"name": "libyaml",
815+
"default-features": false
816+
}
817+
],
818+
"builtin-baseline": "9f5925e81bbcd9c8c34cc7a8bd25e3c557b582b2"
819+
}
820+
```
821+
822+
4. **Install dependencies using `vcpkg`**
823+
824+
```bash
825+
vcpkg install --triplet x64-windows-static
826+
```
827+
828+
You should see output like:
829+
830+
```bash
831+
libyaml:x64-windows-static 0.2.5#5 A C library for parsing and emitting YAML.
832+
openssl:x64-windows-static 3.3.2#1 OpenSSL is an open source project that provides SSL and TLS.
833+
```
834+
835+
5. **Link `vcpkg` with Visual Studio**
836+
837+
```bash
838+
vcpkg integrate install
839+
```
840+
841+
6. **Generate the Visual Studio solution of Fluent Bit using CMake**
842+
843+
```bash
844+
cd build
845+
cmake -G "Visual Studio 17 2022" -DFLB_TESTS_INTERNAL=Off -DFLB_TESTS_RUNTIME=Off -DCMAKE_TOOLCHAIN_FILE="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/vcpkg/scripts/buildsystems/vcpkg.cmake" -DOPENSSL_ROOT_DIR=C:/path/to/your/vcpkg_installed/x64-windows-static -DFLB_LIBYAML_DIR=C:/path/to/your/vcpkg_installed/x64-windows-static ..
846+
```
847+
848+
**Notes**:
849+
- Replace `C:/path/to/your/vcpkg_installed/x64-windows-static` with the actual path where `vcpkg` installed OpenSSL and LibYAML.
850+
- When installing with `vcpkg`, you can also specify a different install root using `--x-install-root`.
851+
- This will generate a Visual Studio solution file, which you can open and compile.
852+
853+
7. **Run the binary build**
854+
855+
```bash
856+
cmake --build . --parallel 4 --clean-first
857+
```
858+
859+
**Notes**:
860+
- You can choose to omit the `--parallel` option.
861+
- The `--clean-first` option will clear cache and start a fresh clean build.
862+
734863
### Valgrind
735864
736865
[Valgrind](https://valgrind.org/) is a tool that will help you detect and diagnose memory issues in your code. It will check for memory leaks and invalid memory accesses.

0 commit comments

Comments
 (0)