1 .. SPDX-License-Identifier: BSD-3-Clause
2 Copyright(c) 2010-2014 Intel Corporation.
4 .. _Building_Your_Own_Application:
6 Building Your Own Application
7 =============================
9 Compiling a Sample Application in the Development Kit Directory
10 ---------------------------------------------------------------
12 When compiling a sample application (for example, hello world), the following variables must be exported:
13 RTE_SDK and RTE_TARGET.
15 .. code-block:: console
17 ~/DPDK$ cd examples/helloworld/
18 ~/DPDK/examples/helloworld$ export RTE_SDK=/home/user/DPDK
19 ~/DPDK/examples/helloworld$ export RTE_TARGET=x86_64-native-linuxapp-gcc
20 ~/DPDK/examples/helloworld$ make
23 INSTALL-APP helloworld
24 INSTALL-MAP helloworld.map
26 The binary is generated in the build directory by default:
28 .. code-block:: console
30 ~/DPDK/examples/helloworld$ ls build/app
31 helloworld helloworld.map
33 Build Your Own Application Outside the Development Kit
34 ------------------------------------------------------
36 The sample application (Hello World) can be duplicated in a new directory as a starting point for your development:
38 .. code-block:: console
40 ~$ cp -r DPDK/examples/helloworld my_rte_app
42 ~/my_rte_app$ export RTE_SDK=/home/user/DPDK
43 ~/my_rte_app$ export RTE_TARGET=x86_64-native-linuxapp-gcc
47 INSTALL-APP helloworld
48 INSTALL-MAP helloworld.map
56 The default makefile provided with the Hello World sample application is a good starting point. It includes:
58 * $(RTE_SDK)/mk/rte.vars.mk at the beginning
60 * $(RTE_SDK)/mk/rte.extapp.mk at the end
62 The user must define several variables:
64 * APP: Contains the name of the application.
66 * SRCS-y: List of source files (\*.c, \*.S).
71 It is also possible to build a library in the same way:
73 * Include $(RTE_SDK)/mk/rte.vars.mk at the beginning.
75 * Include $(RTE_SDK)/mk/rte.extlib.mk at the end.
77 The only difference is that APP should be replaced by LIB, which contains the name of the library. For example, libfoo.a.
79 Customize Makefile Actions
80 ~~~~~~~~~~~~~~~~~~~~~~~~~~
82 Some variables can be defined to customize Makefile actions. The most common are listed below. Refer to
83 :ref:`Makefile Description <Makefile_Description>` section in
84 :ref:`Development Kit Build System <Development_Kit_Build_System>`
88 * VPATH: The path list where the build system will search for sources. By default,
89 RTE_SRCDIR will be included in VPATH.
91 * CFLAGS_my_file.o: The specific flags to add for C compilation of my_file.c.
93 * CFLAGS: The flags to use for C compilation.
95 * LDFLAGS: The flags to use for linking.
97 * CPPFLAGS: The flags to use to provide flags to the C preprocessor (only useful when assembling .S files)
99 * LDLIBS: A list of libraries to link with (for example, -L /path/to/libfoo - lfoo)