
libpcap-dev for Cygwin
May 26, 2021
When compiling programs from source in Cygwin, an error may occur containing the line “when searching for -lwpcap”.
The essence of the error is that the headers of the pcap library are searched.
These header files are present in the libpcap-dev package (Debian and derivatives). This package may also be called libpcap (for example, on Arch Linux). There are no such packages in the Cygwin repositories, since their functioning is closely related to the operating system drivers and libpcap is intended for Linux, while Cygwin runs on Windows.
When traversing the file system looking for the correct header files, the following messages may be displayed:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /lib/../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /lib/../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /lib/../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/../lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/libwpcap.a when searching for -lwpcap /usr/lib/gcc/x86_64-pc-cygwin/4.9.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lwpcap collect2: error: ld returned 1 exit status
As an alternative to libpcap for Windows (and therefore also for Cygwin) you can use:
- WinPCAP – popular software, but no longer developed and maintained
- Npcap – based on WinPCAP and is actively developing at the present time
To compile programs that require the libpcap library, you need source files, WinPCAP or Npcap headers.
The WinPCAP header files are in the Developer's Pack, and the Npcap header files can be found in the Npcap SDK.
WinPCAP for Cygwin
Follow the steps below to install WinPCAP headers in Cygwin.
Go to https://www.winpcap.org/devel.htm and download the developer pack.
Unpack the downloaded archive.
Copy the libraries:
- WpdPack\Lib\libpacket.a in cygwin\lib\
- WpdPack\Lib\libwpcap.a in cygwin\lib\
Copy headers from WpdPack\Include to cygwin\usr\include\.
Make sure you have the Winpcap libraries installed and that they are available in the PATH by running the commands:
which Packet.dll which wpcap.dll
They should be in /cygdrive/c/WINDOWS/system32/.
Npcap for Cygwin
Go to https://nmap.org/npcap/ and download the Npcap SDK.
Unpack the downloaded archive.
Copy headers from Include to cygwin\usr\include\.
Make sure you have the Npcap libraries installed and that they are available in the PATH by running the commands:
which Packet.dll which wpcap.dll
They should be in /cygdrive/c/WINDOWS/system32/.
Related articles:
- How to check if a package is installed on Linux Mint (72.2%)
- WordPress: A critical error occurred on the site – impossible to enter the control panel (SOLVED) (72.2%)
- How to install VirtualBox Guest Additions in Linux LMDE (72.2%)
- How to configure Linux LMDE login without entering a password (72.2%)
- Error in LMDE “cryptsetup: WARNING: The initramfs image may not contain cryptsetup binaries nor crypto modules” (SOLVED) (72.2%)
- How to allow a user to access only certain columns in MySQL (MariaDB) (RANDOM - 64.4%)