Michele Locati <[email protected]> writes in
<https://lists.gnu.org/archive/html/bug-gettext/2026-01/msg00029.html>:

> /usr/lib/gcc/x86_64-w64-mingw32/13/../../../../x86_64-w64-mingw32/bin/ld:
> ../lib/.libs/libtextstyle.a(libtextstyle_la-xgethostname.o):xgethostname.c:(.text+0xab):
>  undefined reference to `rpl_gethostname'
> collect2: error: ld returned 1 exit status

Thanks for the report. This patch should fix it.


2026-01-12  Bruno Haible  <[email protected]>

        gethostname: Fix link error on native Windows.
        Reported by Michele Locati <[email protected]> in
        <https://lists.gnu.org/archive/html/bug-gettext/2026-01/msg00029.html>.
        * modules/gethostname (Dependencies, configure.ac): Compile
        gethostname.c also when UNISTD_H_HAVE_WINSOCK2_H is 1.

diff --git a/modules/gethostname b/modules/gethostname
index 093d13a132..8737ef31df 100644
--- a/modules/gethostname
+++ b/modules/gethostname
@@ -8,15 +8,16 @@ lib/w32sock.h
 
 Depends-on:
 unistd-h
-sys_socket-h    [test $HAVE_GETHOSTNAME = 0]
-errno-h         [test $HAVE_GETHOSTNAME = 0]
-sockets         [test $HAVE_GETHOSTNAME = 0]
-msvc-nothrow    [test $HAVE_GETHOSTNAME = 0]
+sys_socket-h    [test $HAVE_GETHOSTNAME = 0 || test $UNISTD_H_HAVE_WINSOCK2_H 
= 1]
+errno-h         [test $HAVE_GETHOSTNAME = 0 || test $UNISTD_H_HAVE_WINSOCK2_H 
= 1]
+sockets         [test $HAVE_GETHOSTNAME = 0 || test $UNISTD_H_HAVE_WINSOCK2_H 
= 1]
+msvc-nothrow    [test $HAVE_GETHOSTNAME = 0 || test $UNISTD_H_HAVE_WINSOCK2_H 
= 1]
 strncpy         [test $HAVE_GETHOSTNAME = 0]
 
 configure.ac:
 gl_FUNC_GETHOSTNAME
-gl_CONDITIONAL([GL_COND_OBJ_GETHOSTNAME], [test $HAVE_GETHOSTNAME = 0])
+gl_CONDITIONAL([GL_COND_OBJ_GETHOSTNAME],
+               [test $HAVE_GETHOSTNAME = 0 || test $UNISTD_H_HAVE_WINSOCK2_H = 
1])
 AM_COND_IF([GL_COND_OBJ_GETHOSTNAME], [
   gl_PREREQ_GETHOSTNAME
 ])




Reply via email to