Loading...
X

libpcap-dev for Cygwin

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/.


Leave Your Observation

Your email address will not be published. Required fields are marked *