# Getting Started If you just want to install eBPF for Windows on a machine to experiment with, jump down to [Installing eBPF for Windows](#installing-ebpf-for-windows). If you just want to compile, but not run, eBPF programs and applications that interact with them, jump down to [Using eBPF in development](#using-ebpf-in-development). ## Building eBPF for Windows ### Prerequisites The following must be installed in order to build this project: 1. Git (e.g., [Git for Windows 64-bit](https://git-scm.com/download/win)) 1. **Visual Studio 2022** - one of the following editions should be installed (once installed, upgrade to **v17.4.2 or later**): - [Download Visual Studio Community 2022](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=17) (free) - [Download Visual Studio Professional 2022](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Professional&rel=17) - [Download Visual Studio Enterprise 2022](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Enterprise&rel=17) Visual Studio will [prompt you to install](https://learn.microsoft.com/en-us/visualstudio/install/import-export-installation-configurations?view=vs-2019#use-a-configuration-file-to-automatically-install-missing-components) the necessary dependencies when opening the main solution file for the first time. 1. Install [Clang for Windows 64-bit](https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/LLVM-18.1.8-win64.exe) (version **18.1.8**). The latest version of clang that ships with the Visual Studio installer does not support `bpf` as a target. You should add the paths to `git.exe`, `cmake.exe` and `nuget.exe` to the Windows PATH environment variable after the software packages above have been installed. **Alternative install steps to install Visual Studio and the required dependencies (for *basic* Visual Studio Community edition):** 1. Launch an administrative PowerShell session. 1. Install [Chocolatey Package Manager for Windows](https://chocolatey.org/install) by running the following commands in the PowerShell session: ```ps Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) ``` 1. Run the following command to automatically set up the dev environment: ```ps Invoke-WebRequest 'https://raw.githubusercontent.com/microsoft/ebpf-for-windows/main/scripts/Setup-DevEnv.ps1' -OutFile $env:TEMP\Setup-DeveEnv.ps1 if ((get-filehash -Algorithm SHA256 $env:TEMP\Setup-DeveEnv.ps1).Hash -eq 'B12416D3C84660BE33C88772B3E7D3571A10899A57BC9DDFE218DB751483FD71') { &"$env:TEMP\Setup-DeveEnv.ps1" } ``` >**Note**: the WDK for Windows 11 is [not currently available on Chocolatey](https://community.chocolatey.org/packages?q=windowsdriverkit), please install manually with the link in the [Prerequisites](#prerequisites) section above. ### How to clone and build the project using Visual Studio This section outlines the steps to build, prepare and build the eBPF-For-Windows project. #### Cloning the project Clone the eBPF for Windows projects and its submodules by running: ```cmd git clone --recurse-submodules https://github.com/microsoft/ebpf-for-windows.git ``` >Note: by default this will clone the project under the `ebpf-for-windows` directory. #### Exclusion of PE parse directory from Windows Defender Antivirus PE parse directory includes some malformed PE images as a part of the test suite for PE image parser and Windows Defender flags these files as viruses. Please note that similar exclusions have to be done for other Antivirus products as needed. The following steps are needed to exempt PE directory from Windows Defender Antivirus: 1. Select *Start*, then open *Settings*. Under *Privacy & Security*, select *Virus & threat protection*. 1. Under *Virus & threat protection* settings, select *Manage settings*, and then under *Exclusions*, select *Add or remove exclusions*. 1. Select *Add an exclusion*, and then select from files, folders, file types, or processes. Choose the following directory ```ebpf-for-windows/external/pe-parse``` to exclude the folder and subfolders to get flagged by the antivirus. #### Prepare for first build The following steps need to be executed *once* before the first build on a new clone: 1. Launch a `Developer PowerShell for VS 2022` session. 1. Change directory to where the project is cloned (e.g. "`cd ebpf-for-windows`"). 1. Run the following script: ```ps .\scripts\initialize_ebpf_repo.ps1 ``` >**Note**: you may get the following transitory error, which can be safely ignored as the *WiX Toolset* nuget package will be installed immediately afterwards: > > `error : The WiX Toolset v3.14.1 build tools must be installed to build this project. To download the WiX Toolset, see https://github.com/wixtoolset/wix3/releases/tag/wix3141rtm` > TIP: In case you need to "reset" the repo, without re-cloning it, you can just delete all the folders under the `\external` directory (but keep the files), and then re-run the above script. #### Building using Developer Command Prompt for VS 2022 1. Launch `Developer Command Prompt for VS 2022`. 1. Change directory to where the project is cloned (e.g. `cd ebpf-for-windows`), and run the following command: ```cmd msbuild /m /p:Configuration=Debug /p:Platform=x64 ebpf-for-windows.sln ``` ##### Setting compile time options when building from Developer Command Prompt To build with the specific compile time options for disabling JIT compiler and/or the Interpreter, append "`/p: