On QNX with the following testdir:
$ gnulib-tool --create-testdir --dir testdir1 inet_ntop
I see the following:
$ ./configure | grep inet_ntop
checking for library containing inet_ntop... no
checking for inet_ntop... no
checking whether inet_ntop is declared... yes
$ make
[...]
gcc -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -I/usr/include
-D_QNX_SOURCE --sysroot=/ -MT inet_ntop.o -MD -MP -MF .deps/inet_ntop.Tpo -c -o
inet_ntop.o inet_ntop.c
inet_ntop.c: In function 'rpl_inet_ntop':
inet_ntop.c:58:10: warning: implicit declaration of function 'inet_ntop';
did you mean 'inet_ntoa'? [-Wimplicit-function-declaration]
58 | return inet_ntop (af, src, dst, cnt);
| ^~~~~~~~~
| inet_ntoa
inet_ntop.c:58:10: warning: returning 'int' from a function with return
type 'const char *' makes pointer from integer without a cast [-Wint-conversion]
58 | return inet_ntop (af, src, dst, cnt);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mv -f .deps/inet_ntop.Tpo .deps/inet_ntop.Po
[...]
gcc -Wno-error -Wno-error -I/usr/include -D_QNX_SOURCE --sysroot=/
-L/usr/lib -shared-libgcc -o test-inet_ntop test-inet_ntop.o libtests.a
../gllib/libgnu.a libtests.a ../gllib/libgnu.a libtests.a
//usr/bin/ntox86_64-ld: test-inet_ntop.o: in function `main':
test-inet_ntop.c:(.text+0x35): undefined reference to `__inet_ntop'
//usr/bin/ntox86_64-ld: test-inet_ntop.o:(.data.rel+0x0): undefined
reference to `__inet_ntop'
collect2: error: ld returned 1 exit status
[...]
QNX's socket documentation is terrible and just says to go look at
FreeBSD's documentation, which has this function in libc [1]. We can
figure out where inet_ntop is by ourselves with the following:
$ for file in /usr/lib/*.so; do \
nm -D "$file" 2>/dev/null \
| grep -qF 'inet_ntop' && echo "$file"; \
done
/usr/lib/libasan.so
/usr/lib/libgettextlib-0.26.so
/usr/lib/libgettextlib.so
/usr/lib/libgio-2.0.so
/usr/lib/librimrtp.so
/usr/lib/libsocket.so
/usr/lib/mm-stream-server-rtsp.so
So we have to link to -lsocket.
The same goes for inet_pton. I pushed the attached patch to fix both of
those.
[1]
https://www.qnx.com/developers/docs/8.0/com.qnx.doc.neutrino.io_sock/topic/socket_api.html
>From 7c53b3de8e9357d63f034bb38d0eba6b32186d0e Mon Sep 17 00:00:00 2001
Message-ID: <7c53b3de8e9357d63f034bb38d0eba6b32186d0e.1767241367.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Wed, 31 Dec 2025 20:20:49 -0800
Subject: [PATCH] inet_ntop, inet_pton: Fix a link error on QNX.
* m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): Also check for inet_ntop in
libsocket.
* m4/inet_pton.m4 (gl_FUNC_INET_PTON): Likewise for inet_pton.
---
ChangeLog | 5 +++++
m4/inet_ntop.m4 | 5 +++--
m4/inet_pton.m4 | 5 +++--
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 85628fbf0c..fd4314ef8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2025-12-31 Collin Funk <[email protected]>
+ inet_ntop, inet_pton: Fix a link error on QNX.
+ * m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): Also check for inet_ntop in
+ libsocket.
+ * m4/inet_pton.m4 (gl_FUNC_INET_PTON): Likewise for inet_pton.
+
sys_stat-h tests: Fix a static_assert failure on QNX.
* tests/test-sys_stat-h.c [__QNX__]: Don't check that blksize_t and
blkcnt_t are signed. Add some parentheses for readability.
diff --git a/m4/inet_ntop.m4 b/m4/inet_ntop.m4
index 693bd51bcf..e9843626ad 100644
--- a/m4/inet_ntop.m4
+++ b/m4/inet_ntop.m4
@@ -1,5 +1,5 @@
# inet_ntop.m4
-# serial 22
+# serial 23
dnl Copyright (C) 2005-2006, 2008-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -19,6 +19,7 @@ AC_DEFUN([gl_FUNC_INET_NTOP]
dnl Solaris 8..10 provide inet_ntop in libnsl instead.
dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
dnl Haiku provides it in -lnetwork.
+ dnl QNX provides it in -lsocket.
dnl Native Windows provides it in -lws2_32 instead, with a declaration in
dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
@@ -39,7 +40,7 @@ AC_DEFUN([gl_FUNC_INET_NTOP]
fi
else
gl_saved_LIBS=$LIBS
- AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
+ AC_SEARCH_LIBS([inet_ntop], [nsl resolv network socket], [],
[AC_CHECK_FUNCS([inet_ntop])
if test $ac_cv_func_inet_ntop = no; then
HAVE_INET_NTOP=0
diff --git a/m4/inet_pton.m4 b/m4/inet_pton.m4
index b6e59a25ce..1426cb0974 100644
--- a/m4/inet_pton.m4
+++ b/m4/inet_pton.m4
@@ -1,5 +1,5 @@
# inet_pton.m4
-# serial 20
+# serial 21
dnl Copyright (C) 2006, 2008-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -19,6 +19,7 @@ AC_DEFUN([gl_FUNC_INET_PTON]
dnl Solaris 8..10 provide inet_pton in libnsl instead.
dnl Solaris 2.6..7 provide inet_pton in libresolv instead.
dnl Haiku provides it in -lnetwork.
+ dnl QNX provides it in -lsocket.
dnl Native Windows provides it in -lws2_32 instead, with a declaration in
dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
@@ -39,7 +40,7 @@ AC_DEFUN([gl_FUNC_INET_PTON]
fi
else
gl_saved_LIBS=$LIBS
- AC_SEARCH_LIBS([inet_pton], [nsl resolv network], [],
+ AC_SEARCH_LIBS([inet_pton], [nsl resolv network socket], [],
[AC_CHECK_FUNCS([inet_pton])
if test $ac_cv_func_inet_pton = no; then
HAVE_INET_PTON=0
--
2.52.0