Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile on Windows CMake issue #1225

Open
joesulewski opened this issue Oct 4, 2024 · 7 comments
Open

Compile on Windows CMake issue #1225

joesulewski opened this issue Oct 4, 2024 · 7 comments

Comments

@joesulewski
Copy link

joesulewski commented Oct 4, 2024

Hello,

I'm attempting to compile tcpdump on Windows 11 using version 1.13 of the NPCap SDK and Visual Studio 17 2022. I'm getting an error that libpcap is too old; 1.0 or later is required but I'm using the 1.13 version of the SDK.

I looked at the pcap.h file and it has the following:

PCAP_AVAILABLE_1_0
PCAP_API pcap_t *pcap_create(const char *, char *);

PCAP_AVAILABLE_1_0
PCAP_API const char *pcap_statustostr(int);

Thank you for any help you can offer.

 I issue the following command:
cmake "-DPCAP_ROOT=\development\npcap-sdk-1-13" -G "Visual Studio 17 2022" -A Win32 ..

And I receive the following output:
-- The C compiler identification is MSVC 19.41.34120.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Building 32-bit
-- Use DYNAMIC runtime
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Looking for rpc/rpc.h
-- Looking for rpc/rpc.h - not found
-- Looking for strlcat
-- Looking for strlcat - not found
-- Looking for strlcpy
-- Looking for strlcpy - not found
-- Looking for strsep
-- Looking for strsep - not found
-- Looking for gethostbyaddr
-- Looking for gethostbyaddr - found
-- Looking for getservent
-- Looking for getservent - not found
-- Looking for getservent
-- Looking for getservent - not found
-- Skipped SUITABLE_SNPRINTF because cross-compiling.
-- Looking for getopt_long
-- Looking for getopt_long - not found
-- Looking for getrpcbynumber
-- Looking for getrpcbynumber - not found
-- Looking for getrpcbynumber
-- Looking for getrpcbynumber - not found
-- Looking for ether_ntohost
-- Looking for ether_ntohost - not found
-- Found PCAP: //development/npcap-sdk-1-13/include
-- Looking for pcap/pcap-inttypes.h
-- Looking for pcap/pcap-inttypes.h - not found
-- Looking for pcap_create
-- Looking for pcap_create - not found
CMake Error at CMakeLists.txt:778 (MESSAGE):
libpcap is too old; 1.0 or later is required

-- Configuring incomplete, errors occurred!

@joesulewski
Copy link
Author

joesulewski commented Oct 7, 2024

(formatting applied to display the slashes correctly -- Denis)

Okay, I found the issue. On windows you have to use forward slashes for the CMake comand prompt. For example:

cmake -DPCAP_ROOT=/development/npcap-sdk-1-13 -G "Visual Studio 17 2022" -A Win32 /development/tcpdump

do not use double backslashes like so

cmake -DPCAP_ROOT=\\development\\npcap-sdk-1-13 -G "Visual Studio 17 2022" -A Win32 /development/tcpdump

I'm just getting back to C++ so if this seems obvious my apologies.

@guyharris
Copy link
Member

On windows you have to use forward slashes for the CMake comand prompt.

That's hyper-spectacularly broken. I'll try to figure out what needs to be done to fix that.

@infrastation
Copy link
Member

It seems possible that CMake takes both slashes and backslashes as valid input and then converts as is necessary for the OS (note the C:/Program Files/ above), but the \\ at the beginning of the path makes it treat the path as a Windows network resource, which then fails. I do not have an environment to confirm this.

@guyharris
Copy link
Member

I'm not seeing that problem on my Windows 11 VM.

I followed the instructions at https://github.com/the-tcpdump-group/tcpdump/blob/master/doc/README.windows.md, in an "x64 Native Tools Command Prompt for VS 2022" window. Those instructions use single backslashes, not double backslashes.

@guyharris
Copy link
Member

On a side note, your documentation for Windows should include defining PCAP_INCLUDE_DIR and the PCAP_LIBRARY in addition to PCAP_ROOT.

Why? In my tests, it worked without that; the CMake script itself sets those. (find_path(), in CMake 3.12 and later, will, when searching for a package with a given name, search in the appropriate subdirectory of the {package name}_ROOT directory. We require CMake 3.12 and later on Windows.)

@joesulewski
Copy link
Author

On a side note, your documentation for Windows should include defining PCAP_INCLUDE_DIR and the PCAP_LIBRARY in addition to PCAP_ROOT.

Why? In my tests, it worked without that; the CMake script itself sets those. (find_path(), in CMake 3.12 and later, will, when searching for a package with a given name, search in the appropriate subdirectory of the {package name}_ROOT directory. We require CMake 3.12 and later on Windows.)

Guy,

I should have removed that from my original comment. I was using \ and cmake doesn't throw errors, it actually tells you it can't find PCAP_INCLUDE_DIR and PCAP_LIBRARY which I interpreted as needing to be added. I'll edit the comment and remove it.
THanks for all the help!

@joesulewski
Copy link
Author

I'm not seeing that problem on my Windows 11 VM.

I followed the instructions at https://github.com/the-tcpdump-group/tcpdump/blob/master/doc/README.windows.md, in an "x64 Native Tools Command Prompt for VS 2022" window. Those instructions use single backslashes, not double backslashes.

Guy,

I just looked at the directions and the only reference I see to slashes is in the Visual Studio 2017 GUI section where it says to use double backslashes, not forward slashes. Perhaps I'm missing something, but I don't see any examples or explanation that on the commandline to use forward slashes when defining the PCAP_ROOT variable.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants