I am using libpcap to capture some UDP packets from ethernet interface connected to my linux based ARM aarch64 Hardware. I am compiling the code in the host computer with ubuntu 16.04, using cmake3.5.1, libpcap1.9.1, and code is written in c++.
To cross compile the libpcap, I followed this link (https://kush.com.fj/blog/posts/2018-05-15-crosscompile-libpcap-for-arm/). After cross compiling I need to add these cross compiled target libraries into the CMakeLists.txt for cmake compiler to understand. I would like to understand how I should add these links in what way in CMakeLists.txt file.
I have two CMakeLists.txt present. One for the big projects folder and one inside the source of the project folder. My Folder structure looks like : Eth_read ->build_host ->build_target ->cmake ->src ->eth_read ->main.cpp ->CMakeLists.txt (sub-cmakelists.txt) ->CMakeLists.txt (main-cmakelists.txt for projects)
--The main CMakeLists.txt is as below:
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(PCAP_LIBRARY /home/rsidhan1/Downloads/libpcap-1.9.1/libpcap.so.1.9.1) // this file was created after building for ARM
Project(Testing C CXX)
include_directories(/home/rsidhan1/Downloads/libpcap-1.9.1/)
set(PROJECTS eth_read)
foreach(PROJECT ${PROJECTS})
add_subdirectory(src/${PROJECT})
endforeach()
--The sub CMakeLists.txt is as below:
project(eth_read C CXX)
set(PUBLIC_DOCS
README.md
)
set(SOURCES
main.cpp
)
target_link_libraries(eth_read /home/rsidhan1/Downloads/libpcap-1.9.1/)
I have a main.cpp where I use the function from pcap.h to open the interface, to capture packets and to callback function to process those packets.
I would like to know how to add the cross compiled libraries in the CMakeLists.txt and use the cross compiled binary file in hardware to listen to Ethernet interface. Please let me know if I am missing something or doing something wrong here.