npcap
npcap copied to clipboard
pkg-config support
pkg-config tool can work on Windows and libpcap upstream has libpcap.pc
. Can npcap SDK provide this file on Windows? It would eliminate libpcap.a
/wpcap.lib
difference for cross-platform projects that use pkg-config, e.g. via meson build system.
Probably 32-bit and 64-bit folder should have their own .pc files, so that they are selected by PKG_CONFIG_PATH
.
Prefix path can be set to some recommended location to install SDK, like C:\Program Files\Npcap
.
(Update: on Windows, pkg-config can detect prefix if file is placed inside ${prefix}/lib/pkgconfig
.)
Example file:
prefix="C:/Program Files/Npcap"
Name: libpcap
Version: 1.10
Description: Platform-independent network traffic capture library
Cflags: -I${prefix}/Include
Libs: -L${prefix}/Lib/x64 -lwpcap
Or, if it's feasible to change installation layout, this way $prefix
could be calculated automatically:
C:/Program Files/Npcap/
Include/
x64/
Lib/
wpcap.lib
pkgconfig/
libpcap.pc
x86/
(ditto)
Probably 32-bit and 64-bit folder should have their own .pc files, so that they are selected by PKG_CONFIG_PATH.
So is there a convention used on UN*Xes to deal with cross-building (which includes building for 32-bit on 64-bit and building for 64-bit on 32-bit)? If so, the same convention should probably be used on Windows (there's nothing inherently special about Npcap here; that would apply to all libraries).
On Unices binaries are installed to prefixes like /lib/i686-linux-gnu
or /lib/x86_64-linux-gnu
and so do *.pc
files. Pkg-config searches packages by filename without .pc
in PKG_CONFIG_PATH
, which contains paths under appropriate prefix. So Npcap only has to place libpcap.pc
(this exact name) in different folders for x86 and x64.
Bump. Is there a decision if Npcap will integrate pkg-config support? If it will, shall directory layout be changed? How can I help besides providing libpcap.pc above?
Thanks for the suggestion. So far we haven't received many requests for this, but this issue is a good place for people to comment if they are interested in pkg-config support for Npcap and why. Npcap OEM customers can also request it through their support channel and we will tally those requests as well. Also, does upstream libpcap support this?
Upstream libpcap supports pkg-config from 1.9.0. My use case is Npcap being an optional dependency of DPDK on Windows. DPDK uses pkg-config as the primary dependency locator on all platforms.
Also, does upstream libpcap support this?
"This" meaning what?
Both autotools and CMake builds of libpcap will, if you do make install
with autotools or whatever builds the install
target with CMake, install a libpcap.pc
file.
For an autotools file, it will be installed in $(DESTDIR)$(libdir)/pkgconfig/libpcap.pc
; that would only install under lib/i686-linux-gnu
or /lib/x86_64-linux-gnu
if DESTDIR
and libdir
are set appropriately when ./configure
is run; it doesn't, as far as I know, do so automatically. Note that
On Unices binaries are installed to prefixes like
/lib/i686-linux-gnu
or/lib/x86_64-linux-gnu and
so do*.pc
files.
may be true of some UN*Xes but not all. On multi-architecture systems:
- macOS (and other Darwin-based OSes) don't have separate paths because a single binary would include code for multiple architectures - you don't have one file with 32-bit x86 code and another file with 64-bit x86 code, you have a single file with both 32-bit and 64-bit code in it, and you don't have one file with 64-bit x86 code and another file with 64-bit ARM code you have a single file with both 64-bit x86 and 64-bit ARM code (and, back in the day, you might have had a file with 32-bit PowerPC, 64-bit PowerPC, 32-bit x86, and 64-bit x86 code in it). As such, you don't have separate
.pc
files for separate target architectures. - Solaris has
/usr/lib
for 32-bit libraries and/usr/lib/{sparcv9,amd64}
for 64-bit libraries, and haspkgconfig
directories under both of them for.pc
files. - FreeBSD appears to have
/usr/lib
for 64-bit libraries and/usr/lib32
for 32-bit libraries; it doesn't (yet?) natively provide pkg-config, but if it ever does (which would probably happen by picking up OpenBSD's non-GPL reimplementation), they'd probably havepkgconfig
under those directories. I don't know what the other BSDs do. - I don't know what AIX does.
- I don't know what various now-dead UN*Xes did or what UN*Xes on a death watch (HP-UX, which apparently isn't going to be ported to 64-bit x86) do.
So the answer to "So is there a convention used on UN*Xes to deal with cross-building (which includes building for 32-bit on 64-bit and building for 64-bit on 32-bit)?" appears to be "No, there isn't a convention, there are several of them, and which one is used depends on the UN*X you're using."
This means that Npcap isn't constrained by what various UN*Xes have done. It should do whatever works best in Windows build environments.
The current installation layout for the SDK is
C:/{wherever you install it}/
Include/
Lib/
Packet.lib
wpcap.lib
x64/
Packet.lib
wpcap.lib
I don't know what issues modifying the installation layout to the proposed layout would cause for existing projects.
(Update: on Windows, pkg-config can detect prefix if file is placed inside ${prefix}/lib/pkgconfig.)
So where is the Windows pkg-config port, including the documentation where that's mentioned?
may be true of some UN*Xes but not all.
Thanks a lot for enlightening, I stand corrected.
(Update: on Windows, pkg-config can detect prefix if file is placed inside ${prefix}/lib/pkgconfig.)
So where is the Windows pkg-config port, including the documentation where that's mentioned?
It's not a port, pkg-config upstream supports Windows. Official binaries are here:
- https://ftp.acc.umu.se/pub/GNOME/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip
- https://download-fallback.gnome.org/binaries/win32/glib/2.28/glib_2.28.8-1_win32.zip
- https://ftp.acc.umu.se/pub/GNOME/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip
Documentation for the mentioned feature: https://gitlab.freedesktop.org/pkg-config/pkg-config/-/blob/master/README.win32#L17