tcpdump mailing list archives

CMake fails to detect <net/bpf.h> on QNX 8.0.


From: Denis Ovsienko <denis () ovsienko info>
Date: Sat, 1 Aug 2026 14:31:34 +0100

Hello all.

There is a traditional peculiarity of the build systems I came across
and could not explain.  It starts seemingly simple: a native build of
libpcap (the current master branch with a couple WIP commits on top) on
QNX SDP 8.0.5 works using Autoconf, but fails using CMake 4.2.3.

Autoconf:
checking for net/bpf.h... yes
checking for sys/ioccom.h... yes
checking if net/bpf.h defines BIOCSETIF... yes
checking packet capture type... bpf

CMake:
-- Looking for getaddrinfo
-- Looking for getaddrinfo - not found
-- Looking for getaddrinfo in socket
-- Looking for getaddrinfo in socket - not found
-- Looking for getaddrinfo in network
-- Looking for getaddrinfo in network - not found
CMake Error at CMakeLists.txt:933 (message):
  getaddrinfo is required, but wasn't found


The latter is the result of 9 compiler errors along the lines of:
/usr/include/net/bpf.h:45:9: error: unknown type name 'uint32_t'; did
  you mean 'uint_t'?


To solve the problem, it is sufficient to include `stdint.h` beforehand:
--------------------------------------------------------------------
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1949,7 +1949,7 @@ else()
         # It is not one of the above obvious types, let's see if it is BPF.
         # Check this before DLPI to pick BPF on Solaris 11 and later.
         #
-        check_include_files("sys/types.h;net/bpf.h" HAVE_NET_BPF_H)
+        check_include_files("sys/types.h;stdint.h;net/bpf.h"
  HAVE_NET_BPF_H) if(HAVE_NET_BPF_H)
             #
             # HAVE_SYS_IOCCOM_H will be required for a few workarounds
  until all @@ -1987,13 +1987,16 @@ else()
             #  defines some structure fields as being
             #  struct sockaddrs;
             #
+            #  stdint.h, because in QNX 8.0 net/bpf.h requires
+            #  that a few integer types be defined;
+            #
             # and net/bpf.h doesn't necessarily include all
             # of those headers itself.
             #
             if(HAVE_SYS_IOCCOM_H)
-                check_symbol_exists(BIOCSETIF
  "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;sys/ioccom.h;net/bpf.h;net/if.h"
  BPF_H_DEFINES_BIOCSETIF)
+                check_symbol_exists(BIOCSETIF
  "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;sys/ioccom.h;stdint.h;net/bpf.h;net/if.h"
  BPF_H_DEFINES_BIOCSETIF) else(HAVE_SYS_IOCCOM_H)
-                check_symbol_exists(BIOCSETIF
  "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;net/bpf.h;net/if.h"
  BPF_H_DEFINES_BIOCSETIF)
+                check_symbol_exists(BIOCSETIF
  "sys/types.h;sys/time.h;sys/ioctl.h;sys/socket.h;stdint.h;net/bpf.h;net/if.h"
  BPF_H_DEFINES_BIOCSETIF) endif(HAVE_SYS_IOCCOM_H)
  endif(HAVE_NET_BPF_H) 
--------------------------------------------------------------------


Then CMake works as expected:
-- Looking for 3 include files sys/types.h, ..., net/bpf.h
-- Looking for 3 include files sys/types.h, ..., net/bpf.h - found
-- Looking for sys/ioccom.h
-- Looking for sys/ioccom.h - found
-- Looking for BIOCSETIF
-- Looking for BIOCSETIF - found
-- Packet capture mechanism type: bpf


However, I did not commit this change because two things look off.
First, what does Autoconf do differently in the same environment to
compile its test programs (below) fine without explicitly including
<stdint.h>, and should CMake do the same instead of piling <stdint.h>
on top?
------------------------------------
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_IOCCOM_H
#include <sys/ioccom.h>
#endif
#include <net/bpf.h>
#include <net/if.h>

int
main (void)
{
u_int i = BIOCSETIF;
  ;
  return 0;
}
------------------------------------


Second, if in the currently implemented logic only <sys/types.h> is
necessary to include <net/bpf.h> successfully and to define
HAVE_NET_BPF_H, then are any other headers really necessary to include
the same header again and to test whether BIOCSETIF is defined?  The
reference to AIX 5.x (end of support in 2012) looks particularly likely
to be a no-op for the currently supported platforms.

-- 
    Denis Ovsienko
_______________________________________________
tcpdump-workers mailing list -- tcpdump-workers () lists tcpdump org
To unsubscribe send an email to tcpdump-workers-leave () lists tcpdump org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s


Current thread: