xref: /dpdk/doc/guides/windows_gsg/build_dpdk.rst (revision f665790a5dbad7b645ff46f31d65e977324e7bfc)
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
75Required version is Meson 0.57.
76
77Versions starting from 0.58 are unusable with LLVM toolchain
78because of a `Meson issue <https://github.com/mesonbuild/meson/issues/8981>`_.
79
80
81Install the Backend
82-------------------
83
84If using Ninja, download and install the backend from
85`Ninja website <https://ninja-build.org/>`_ or
86install along with the meson build system.
87
88Build the code
89--------------
90
91The build environment is setup to build the EAL and the helloworld example by
92default.
93
94Option 1. Native Build on Windows using LLVM
95~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96
97When using Clang-LLVM, specifying the compiler might be required to complete
98the meson command:
99
100.. code-block:: console
101
102    set CC=clang
103
104When using MinGW-w64, it is sufficient to have toolchain executables in PATH:
105
106.. code-block:: console
107
108    set PATH=C:\MinGW\mingw64\bin;%PATH%
109
110To compile the examples, the flag ``-Dexamples`` is required.
111
112.. code-block:: console
113
114    cd C:\Users\me\dpdk
115    meson setup -Dexamples=helloworld build
116    meson compile -C build
117
118Option 2. Cross-Compile with MinGW-w64
119~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120
121The cross-file option must be specified for Meson.
122Depending on the distribution, paths in this file may need adjustments.
123
124.. code-block:: console
125
126    meson setup --cross-file config/x86/cross-mingw -Dexamples=helloworld build
127    ninja -C build
128
129Option 3. Native Build on Windows using MSVC
130~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131
132Open a 'Developer PowerShell for VS 2022' prompt from the start menu.
133The developer prompt will configure the environment
134to select the appropriate compiler, linker and SDK paths
135required to build with Visual Studio 2022.
136
137.. code-block:: console
138
139   cd C:\Users\me\dpdk
140   meson setup -Denable_stdatomic=true build
141   meson compile -C build
142