Compiling DPDK and set environment var
cd dpdk
make config T=x86_64-native-linuxapp-gcc
make -j
export RTE_SDK=$(pwd)
Create CMakeLists.txt file for linking sample app with DPDK
cmake_minimum_required(VERSION 2.8)
SET(PRJ l2fwd)
PROJECT(${PRJ})
SET(SOURCE_EXE main.c)
SET(CMAKE_C_FLAGS "-Wall -Wextra -g -O3 -std=gnu11")
INCLUDE_DIRECTORIES($ENV{RTE_SDK}/build/include)
LINK_DIRECTORIES($ENV{RTE_SDK}/build/lib)
SET(DPDK_LIBS "-Wl,--whole-archive -ldpdk -Wl,--no-whole-archive")
ADD_EXECUTABLE(${PRJ} ${SOURCE_EXE})
TARGET_LINK_LIBRARIES(${PRJ} ${DPDK_LIBS})
TARGET_LINK_LIBRARIES(${PRJ} pthread dl rt m numa)
Run cmake
cmake .
-- The C compiler identification is GNU 6.3.1
-- The CXX compiler identification is GNU 6.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stack/cmake_test
Now run make to build the executable using the generated Makefile
make
Scanning dependencies of target l2fwd
[ 50%] Building C object CMakeFiles/l2fwd.dir/main.c.o
[100%] Linking C executable l2fwd
[100%] Built target l2fwd