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 47Obtain the latest version from 48`MinGW-w64 website <http://mingw-w64.org/doku.php/download>`_. 49On Windows, install to a folder without spaces in its name, like ``C:\MinGW``. 50This path is assumed for the rest of this guide. 51 52Version 4.0.4 for Ubuntu 16.04 cannot be used due to a 53`MinGW-w64 bug <https://sourceforge.net/p/mingw-w64/bugs/562/>`_. 54 55 56Install the Build System 57------------------------ 58 59Download and install the build system from 60`Meson website <http://mesonbuild.com/Getting-meson.html>`_. 61A good option to choose is the MSI installer for both meson and ninja together:: 62 63 http://mesonbuild.com/Getting-meson.html#installing-meson-and-ninja-with-the-msi-installer%22 64 65Recommended version is either Meson 0.47.1 (baseline) or the latest release. 66 67Install the Backend 68------------------- 69 70If using Ninja, download and install the backend from 71`Ninja website <https://ninja-build.org/>`_ or 72install along with the meson build system. 73 74Build the code 75-------------- 76 77The build environment is setup to build the EAL and the helloworld example by 78default. 79 80Option 1. Native Build on Windows 81~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 82 83When using Clang-LLVM, specifying the compiler might be required to complete 84the meson command: 85 86.. code-block:: console 87 88 set CC=clang 89 90When using MinGW-w64, it is sufficient to have toolchain executables in PATH: 91 92.. code-block:: console 93 94 set PATH=C:\MinGW\mingw64\bin;%PATH% 95 96To compile the examples, the flag ``-Dexamples`` is required. 97 98.. code-block:: console 99 100 cd C:\Users\me\dpdk 101 meson -Dexamples=helloworld build 102 ninja -C build 103 104Option 2. Cross-Compile with MinGW-w64 105~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 106 107The cross-file option must be specified for Meson. 108Depending on the distribution, paths in this file may need adjustments. 109 110.. code-block:: console 111 112 meson --cross-file config/x86/meson_mingw.txt -Dexamples=helloworld build 113 ninja -C build 114 115 116Run the helloworld example 117========================== 118 119Navigate to the examples in the build directory and run `dpdk-helloworld.exe`. 120 121.. code-block:: console 122 123 cd C:\Users\me\dpdk\build\examples 124 dpdk-helloworld.exe 125 hello from core 1 126 hello from core 3 127 hello from core 0 128 hello from core 2 129 130Note for MinGW-w64: applications are linked to ``libwinpthread-1.dll`` 131by default. To run the example, either add toolchain executables directory 132to the PATH or copy the library to the working directory. 133Alternatively, static linking may be used (mind the LGPLv2.1 license). 134