I've installed the c++ library pcapplusplus on my linux machine.
Its build system is makefiles and not cmake.
It describes how to compile and an app and provides this makefile about half way down this page.
include /usr/local/etc/PcapPlusPlus.mk
# All Target
all:
g++ $(PCAPPP_INCLUDES) -c -o main.o main.cpp
g++ $(PCAPPP_LIBS_DIR) -static-libstdc++ -o Tutorial-HelloWorld main.o $(PCAPPP_LIBS)
# Clean Target
clean:
rm main.o
rm Tutorial-HelloWorld
I've created a cmaklists file for my project which is below.
Which cmake command should I use for the command include /usr/local/etc/PcapPlusPlus.mk
that is in the makefile.
cmake_minimum_required(VERSION 2.8.9)
project(networksniffer)
# The version number.
set (networksniffer_VERSION_MAJOR 1)
set (networksniffer_VERSION_MINOR 0)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(PROJECT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
# The following folder will be included
include_directories("/usr/local/include/pcapplusplus")
#add_executable(networksniffer ${SOURCES})
add_executable(networksniffer ${PROJECT_SOURCE_DIR}/networksniffer.cpp)
target_link_libraries(${PROJECT_NAME} libCommon++.a libPacket++.a libPcap++.a)
This is the contents of .mk
file.
### COMMON ###
# includes
PCAPPP_INCLUDES := -I/usr/local/include/pcapplusplus
# libs
PCAPPP_LIBS := -lPcap++ -lPacket++ -lCommon++
# post build
PCAPPP_POST_BUILD :=
# build flags
PCAPPP_BUILD_FLAGS :=
### LINUX ###
# includes
PCAPPP_INCLUDES += -I/usr/include/netinet
# libs
PCAPPP_LIBS += -lpcap -lpthread