xref: /dpdk/doc/guides/windows_gsg/build_dpdk.rst (revision daa02b5cddbb8e11b31d41e2bf7bb1ae64dcae2f)
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* The Clang-LLVM C compiler and Microsoft MSVC linker.
14* The MinGW-w64 toolchain (either native or cross).
15
16The Meson Build system is used to prepare the sources for compilation
17with the Ninja backend.
18The installation of these tools is covered in this section.
19
20
21Option 1. Clang-LLVM C Compiler and Microsoft MSVC Linker
22---------------------------------------------------------
23
24Install the Compiler
25~~~~~~~~~~~~~~~~~~~~
26
27Download and install the clang compiler from
28`LLVM website <http://releases.llvm.org/download.html>`_.
29For example, Clang-LLVM direct download link::
30
31	http://releases.llvm.org/7.0.1/LLVM-7.0.1-win64.exe
32
33
34Install the Linker
35~~~~~~~~~~~~~~~~~~
36
37Download and install the Build Tools for Visual Studio to link and build the
38files on windows,
39from `Microsoft website <https://visualstudio.microsoft.com/downloads>`_.
40When installing build tools, select the "Visual C++ build tools" option
41and ensure the Windows SDK is selected.
42
43
44Option 2. MinGW-w64 Toolchain
45-----------------------------
46
47On Linux, i.e. for cross-compilation, install MinGW-w64 via a package manager.
48Version 4.0.4 for Ubuntu 16.04 cannot be used due to a
49`MinGW-w64 bug <https://sourceforge.net/p/mingw-w64/bugs/562/>`_.
50
51On Windows, obtain the latest version installer from
52`MinGW-w64 repository <https://sourceforge.net/projects/mingw-w64/files/>`_.
53Any thread model (POSIX or Win32) can be chosen, DPDK does not rely on it.
54Install to a folder without spaces in its name, like ``C:\MinGW``.
55This path is assumed for the rest of this guide.
56
57
58Install the Build System
59------------------------
60
61Download and install the build system from
62`Meson website <http://mesonbuild.com/Getting-meson.html>`_.
63A good option to choose is the MSI installer for both meson and ninja together::
64
65	http://mesonbuild.com/Getting-meson.html#installing-meson-and-ninja-with-the-msi-installer%22
66
67Recommended version is either Meson 0.57.0 (baseline) or the latest release.
68
69Install the Backend
70-------------------
71
72If using Ninja, download and install the backend from
73`Ninja website <https://ninja-build.org/>`_ or
74install along with the meson build system.
75
76Build the code
77--------------
78
79The build environment is setup to build the EAL and the helloworld example by
80default.
81
82Option 1. Native Build on Windows
83~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84
85When using Clang-LLVM, specifying the compiler might be required to complete
86the meson command:
87
88.. code-block:: console
89
90    set CC=clang
91
92When using MinGW-w64, it is sufficient to have toolchain executables in PATH:
93
94.. code-block:: console
95
96    set PATH=C:\MinGW\mingw64\bin;%PATH%
97
98To compile the examples, the flag ``-Dexamples`` is required.
99
100.. code-block:: console
101
102    cd C:\Users\me\dpdk
103    meson -Dexamples=helloworld build
104    ninja -C build
105
106Option 2. Cross-Compile with MinGW-w64
107~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108
109The cross-file option must be specified for Meson.
110Depending on the distribution, paths in this file may need adjustments.
111
112.. code-block:: console
113
114    meson --cross-file config/x86/cross-mingw -Dexamples=helloworld build
115    ninja -C build
116