安装 libpcap

Install libpcap

有人可以解释一下如何安装 libpcap 吗?我从官方网站 (tcpdump) 下载了 libpcap-1.9.1。有很多文件,我不知道该怎么做。我试过了:

project(test)
set(CMAKE_CXX_STANDARD 14)
include_directories(libpcap-1.9.1)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/libpcap-1.9.1/cmake/Modules")
find_package(Packet REQUIRED)
add_executable(${PROJECT_NAME} main.cpp )
target_link_libraries(${PROJECT_NAME} ${PACKET_LIBRARY})

但是没用

只需使用 add_subdirectory()target_link_libraries():

project(test)

set(CMAKE_CXX_STANDARD 14)

include_directories(libpcap-1.9.1)

add_subdirectory(libpcap-1.9.1)

add_executable(${PROJECT_NAME} main.cpp )

target_link_libraries(${PROJECT_NAME} PRIVATE pcap)