mfontanini / libtins

High-level, multiplatform C++ network packet sniffing and crafting library.
http://libtins.github.io/
BSD 2-Clause "Simplified" License
1.91k stars 377 forks source link

problems compiling with npcap #485

Open MickaMickaMicka opened 2 years ago

MickaMickaMicka commented 2 years ago

I am failing to compile libtins with npcap sdk 1.13 with visual studio 2019 compiler and I dont know whether I am doing it right. I have pthreads as a library in my local development environment. It looks as if it is needed by pcap but isn't found by CMake.

I set

PCAP_INCLUDE_DIR to C:/localpath/npcap-sdk-1.13/Include PCAP_LIBRARY to C:/localpath/npcap-sdk-1.13/Lib/x86/wpcap.lib PCAP_ROOT_DIR to C:/localpath/npcap-sdk-1.13

and I am getting that output:

Found PCAP: C:/localpath/npcap-sdk-1.13/lib/x86/wpcap.lib
Performing Test PCAP_LINKS_SOLO Performing Test PCAP_LINKS_SOLO - Failed Looking for pthread.h Looking for pthread.h - not found Found Threads: TRUE
Performing Test PCAP_NEEDS_THREADS Performing Test PCAP_NEEDS_THREADS - Failed CMake Error at cmake/Modules/FindPCAP.cmake:70 (message): Couldn't determine how to link against libpcap Call Stack (most recent call first): CMakeLists.txt:61 (FIND_PACKAGE)

Configuring incomplete, errors occurred! See also "C:/localpath/libtins-4.4_solution/CMakeFiles/CMakeOutput.log". See also "C:/localpath/libtins-4.4_solution/CMakeFiles/CMakeError.log".

Error message in CMakeError that pthread.h couldnt be opened. That's clear because CMake doesn know where to search for it...

Is there any solution? How can I tell CMake or libtins where to search for pthread?

rectified95 commented 2 years ago

This StackOverflow post contains a long answer that worked for me on Windows. (I built with VS 2022 though and didn't have any pthreads issues. Still it shows how to add inlcude paths which is likely what you need) https://stackoverflow.com/questions/60841031/libtins-sniffer-undefined