1.. SPDX-License-Identifier: BSD-3-Clause 2 Copyright(c) 2019 Intel Corporation. 3 4Compiling the DPDK Target from Source 5===================================== 6 7System Requirements 8------------------- 9 10Building the DPDK and its applications requires one of the following 11environments: 12 13* LLVM 14.0.0 (or later) and Microsoft MSVC linker. 14* The MinGW-w64 10.0 (or later) toolchain (either native or cross). 15* Microsoft Visual Studio 2022 (any edition). 16 17 - note Microsoft Visual Studio 2022 does not currently build enough 18 of DPDK to produce a working DPDK application 19 but may be used to validate that changes are portable between toolchains. 20 21The Meson Build system is used to prepare the sources for compilation 22with the Ninja backend. 23The installation of these tools is covered in this section. 24 25 26Option 1. Clang-LLVM C Compiler and Microsoft MSVC Linker 27--------------------------------------------------------- 28 29Install the Compiler 30~~~~~~~~~~~~~~~~~~~~ 31 32Download and install the clang compiler from 33`LLVM website <http://releases.llvm.org/download.html>`_. 34For example, Clang-LLVM direct download link:: 35 36 http://releases.llvm.org/7.0.1/LLVM-7.0.1-win64.exe 37 38 39Install the Linker 40~~~~~~~~~~~~~~~~~~ 41 42Download and install the Build Tools for Visual Studio to link and build the 43files on windows, 44from `Microsoft website <https://visualstudio.microsoft.com/downloads>`_. 45When installing build tools, select the "Visual C++ build tools" option 46and ensure the Windows SDK is selected. 47 48 49Option 2. MinGW-w64 Toolchain 50----------------------------- 51 52On Windows, obtain the latest version installer from 53`MinGW-w64 repository <https://sourceforge.net/projects/mingw-w64/files/>`_. 54Any thread model (POSIX or Win32) can be chosen, DPDK does not rely on it. 55Install to a folder without spaces in its name, like ``C:\MinGW``. 56This path is assumed for the rest of this guide. 57 58 59Option 3. Microsoft Visual Studio Toolset (MSVC) 60------------------------------------------------ 61 62Install any edition of Microsoft Visual Studio 2022 63from the `Visual Studio website <https://visualstudio.microsoft.com/downloads/>`_. 64 65 66Install the Build System 67------------------------ 68 69Download and install the build system from 70`Meson website <http://mesonbuild.com/Getting-meson.html>`_. 71A good option to choose is the MSI installer for both meson and ninja together:: 72 73 http://mesonbuild.com/Getting-meson.html#installing-meson-and-ninja-with-the-msi-installer%22 74 75The minimal Meson supported version is 1.5.2. 76 77 78Install the Backend 79------------------- 80 81If using Ninja, download and install the backend from 82`Ninja website <https://ninja-build.org/>`_ or 83install along with the meson build system. 84 85Build the code 86-------------- 87 88The build environment is setup to build the EAL and the helloworld example by 89default. 90 91Option 1. Native Build on Windows using LLVM 92~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 94When using Clang-LLVM, specifying the compiler might be required to complete 95the meson command: 96 97.. code-block:: console 98 99 set CC=clang 100 101When using MinGW-w64, it is sufficient to have toolchain executables in PATH: 102 103.. code-block:: console 104 105 set PATH=C:\MinGW\mingw64\bin;%PATH% 106 107To compile the examples, the flag ``-Dexamples`` is required. 108 109.. code-block:: console 110 111 cd C:\Users\me\dpdk 112 meson setup -Dexamples=helloworld build 113 meson compile -C build 114 115Option 2. Cross-Compile with MinGW-w64 116~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 117 118The cross-file option must be specified for Meson. 119Depending on the distribution, paths in this file may need adjustments. 120 121.. code-block:: console 122 123 meson setup --cross-file config/x86/cross-mingw -Dexamples=helloworld build 124 ninja -C build 125 126Option 3. Native Build on Windows using MSVC 127~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 128 129Open a 'Visual Studio Developer Command Prompt'. 130The developer prompt will configure the environment 131to select the appropriate compiler, linker and SDK paths 132required to build with Visual Studio 2022. 133 134Building DPDK applications that run on 32-bit Windows is currently not supported. 135If your Visual Studio environment defaults to producing 32-bit binaries, 136you can instruct the toolset to produce 64-bit binaries using "-arch" parameter. 137For more details about the Developer Prompt options, look at the 138`Visual Studio Developer Command Prompt and Developer PowerShell 139<https://learn.microsoft.com/en-us/visualstudio/ide/reference/command-prompt-powershell?view=vs-2022>`_. 140 141.. code-block:: console 142 143 "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 144 145Compile the code from the developer prompt. 146 147.. code-block:: console 148 149 cd C:\Users\me\dpdk 150 meson setup -Denable_stdatomic=true build 151 meson compile -C build 152