I've installed the c++ library pcapplusplus on my linux machine and the .a files have been put in /usr/local/lib. I am now trying to link my project with it in cmake using target_link_libraries(${PROJECT_NAME} libCommon++.a libPacket++.a libPcap++.a). However, it can't find Packet.h which is part of libPacket++.a. What am I doing wrong here? Do I have to tell cmake where to look?
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)
You need to add header search directory path where compiler can find header file in your case
Packet.hYou can try command
locate Packet.hto find out path on your system. Then you can add that path withinclude_directories()function. i.e. if you foundPacket.hin/usr/local/include/then you should update like below.