microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.36k stars 6.46k forks source link

[winpcap] Build error on x64-windows. Cannot use pcl (with pcap) and libtins together #41067

Open hirenpatel1207 opened 2 months ago

hirenpatel1207 commented 2 months ago

Problem: Cannot use the library pcl (with feature pcap) alongside with the library "libtins". System: x64 Windows The vcpkg.json file: { "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "dependencies": [ { "name":"pcl", "default-features": false, "features": [ "visualization", "pcap" ] }, "libtins" ], "builtin-baseline": "29b2ea2d4b6197e66ef346e62ccbba35b55b7de5" } On building, I get the following error:

[cmake] Installing 6/7 winpcap:x64-windows@4.1.3#12... [cmake] error: The following files are already installed in ..../CMakeHelloWorld/debug/vcpkg_installed/x64-windows and are in conflict with winpcap:x64-windows [cmake] Installed by libpcap:x64-windows
[cmake] include/pcap-bpf.h [cmake] include/pcap-namedb.h [cmake] include/pcap.h [cmake] include/pcap/bluetooth.h [cmake] include/pcap/bpf.h [cmake] include/pcap/namedb.h [cmake] include/pcap/pcap.h [cmake] include/pcap/sll.h [cmake] include/pcap/usb.h [cmake] include/pcap/vlan.h [cmake] [cmake] Elapsed time to handle winpcap:x64-windows: 61.5 ms [cmake] Please ensure you're using the latest port files with git pull and vcpkg update. [cmake] Then check for known issues at: [cmake] https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+winpcap [cmake] You can submit a new issue at: [cmake] https://github.com/microsoft/vcpkg/issues/new?template=report-package-build-failure.md&title=[winpcap]+Build+error+on+x64-windows [cmake] Include '[winpcap] Build error' in your bug report title, the following version information in your bug description, and attach any relevant failure logs from above. [cmake] vcpkg-tool version: 2024-08-01-fd884a0d390d12783076341bd43d77c3a6a15658 [cmake] vcpkg-scripts version: b4624c3a7 2024-09-09 (9 days ago)

Reason: On digging a bit, I found that pcl port for pcap feature check for the system, if it is a windows system, then it uses "winpcap" else "libpcap" which is correct behviour. But the "libtins" library port only builds with "libpcap" i.e. the linux version and is not platform aware. On checking the website for libtins: https://libtins.github.io/download/ , I saw that for building on windows, we can point out to winpcap instead of libpcap. Is this somehow possible via ports too?

dg0yt commented 2 months ago

Moving pcl to libpcap might also be a solution ... if it works.

In #21789, I changed the libtins dependencies from winpcap to libpcap. AFAICS winpcap is still available for download, but no longer maintained. In addition, it is excluded from vcpkg CI.

But libpcap seems to depend on winpcap or the newer Npcap, for Windows. https://github.com/the-tcpdump-group/libpcap/blob/master/doc/README.windows.md I'm not sure if Npcap can be ported. Source code is available, but licensing is restrictive, and dependencies must be checked.

JonLiu1993 commented 2 months ago

This issue could be reproduced with vcpkg 2024-08-01-fd884a0d390d12783076341bd43d77c3a6a15658

dg0yt commented 1 month ago

IIUC libpcap doesn't need all of winpcap, only the packet lib. Would it help to factor out the winpcap packet lib into a separate port which does not conflict with libpcap? (It does not resolve the fact that winpcap is unmaintained.)

AndersBroman commented 1 month ago

Is npcap sdk enough?

dg0yt commented 1 month ago

Is npcap sdk enough?

libpcap 1.10.5 configuration prints:

In order to build a version of libpcap that supports packet capture on Windows, you will need to install Npcap and the Npcap SDK, or WinPcap and the WinPcap SDK, and run cmake with -DPacket_ROOT={path of SDK}, where {path of SDK} is the path name of the top-level directory of the SDK.

I don't know exactly why they write "Npcap and the Npcap SDK". But AFAIU a suitable packet capture lib should come with the SDK.

Unfortunately the SDK's licensing and distribution doesn't seem to make it an attractive candidate for a vcpkg port. So we cannot build with any of the packet capture libs in vcpkg CI at the moment. The new version of the port prints a hint a build time. But I can't test it any further. No local MSVC.