Subject: Motif build failure

From: Ludovic Courtès <[email-masked]>
Date: Mon, 02 Jun 2025 18:01:01 +0200

Hi,

Rutherther <[email-masked]> writes:

> Hi, I've tried looking at one of the failing packages - motif.

The error looks like this:

--8<---------------cut here---------------start------------->8---
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../include -I.. -I./.. -DXMBINDDIR_FALLBACK=\"/gnu/store/lm1p1w0x29w2ypvc8g8nj6k7vharz927-motif-2.3.8-0.59858b0/lib/X11/bindings\" -DINCDIR=\"/gnu/store/lm1p1w0x29w2ypvc8g8nj6k7vharz927-motif-2.3.8-0.59858b0/include/X11\" -DLIBDIR=\"/gnu/store/lm1p1w0x29w2ypvc8g8nj6k7vharz927-motif-2.3.8-0.59858b0/lib/X11\" -I/gnu/store/cm3gmdiv2dmwnld2v5zngc5amsaxnf2b-freetype-2.13.0/include/freetype2 -I/gnu/store/1dlwzyjk51xbn1k7v7b010gidrxxvida-libpng-1.6.39/include/libpng16 -I/gnu/store/cm3gmdiv2dmwnld2v5zngc5amsaxnf2b-freetype-2.13.0/include/freetype2 -I/gnu/store/1dlwzyjk51xbn1k7v7b010gidrxxvida-libpng-1.6.39/include/libpng16 -g -O2 -Wall -g -fno-strict-aliasing -Wno-unused -Wno-comment -I/gnu/store/cm3gmdiv2dmwnld2v5zngc5amsaxnf2b-freetype-2.13.0/include/freetype2 -I/gnu/store/1dlwzyjk51xbn1k7v7b010gidrxxvida-libpng-1.6.39/include/libpng16 -MT XpmWrFFrDat.lo -MD -MP -MF .deps/XpmWrFFrDat.Tpo -c XpmWrFFrDat.c  -fPIC -DPIC -o .libs/XpmWrFFrDat.o
XpmCrBufFrI.c: In function ‘XmeXpmCreateBufferFromXpmImage’:
XpmCrBufFrI.c:155:5: error: implicit declaration of function ‘strcpy’ [-Wimplicit-function-declaration]
  155 |     strcpy(ptr, buf);
      |     ^~~~~~
XpmCrBufFrI.c:47:1: note: include ‘<string.h>’ or provide a declaration of ‘strcpy’
   46 | #include "XpmI.h"
  +++ |+#include <string.h>
   47 | 
XpmCrBufFrI.c:155:5: warning: incompatible implicit declaration of built-in function ‘strcpy’ [-Wbuiltin-declaration-mismatch]
  155 |     strcpy(ptr, buf);
      |     ^~~~~~
XpmCrBufFrI.c:155:5: note: include ‘<string.h>’ or provide a declaration of ‘strcpy’
XpmCrBufFrI.c: In function ‘WriteColors’:
XpmCrBufFrI.c:292:9: error: implicit declaration of function ‘strncpy’ [-Wimplicit-function-declaration]
  292 |         strncpy(s, *defaults++, cpp);
      |         ^~~~~~~
XpmCrBufFrI.c:292:9: note: include ‘<string.h>’ or provide a declaration of ‘strncpy’
XpmCrBufFrI.c:292:9: warning: incompatible implicit declaration of built-in function ‘strncpy’ [-Wbuiltin-declaration-mismatch]
XpmCrBufFrI.c:292:9: note: include ‘<string.h>’ or provide a declaration of ‘strncpy’
XpmCrBufFrI.c:312:9: warning: incompatible implicit declaration of built-in function ‘strcpy’ [-Wbuiltin-declaration-mismatch]
  312 |         strcpy(s, "\",\n");
      |         ^~~~~~
XpmCrBufFrI.c:312:9: note: include ‘<string.h>’ or provide a declaration of ‘strcpy’
XpmCrBufFrI.c:316:45: error: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
  316 |            (*data_size + l - *used_size) <= strlen(buf))
      |                                             ^~~~~~
XpmCrBufFrI.c:316:45: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
--8<---------------cut here---------------end--------------->8---

This is easily addressed with the attached patch.

Unfortunately there are additional failures afterwards:

--8<---------------cut here---------------start------------->8---
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../include -I.. -I./.. -DXMBINDDIR_FALLBACK=\"/gnu/store/jww518240g0h9ffmbn1c3069ly829mhw-motif-2.3.8-0.59858b0/lib/X11/bindings\" -DINCDIR=\"/gnu/store/jww518240g0h9ffmbn1c3069ly829mhw-motif-2.3.8-0.59858b0/include/X11\" -DLIBDIR=\"/gnu/store/jww518240g0h9ffmbn1c3069ly829mhw-motif-2.3.8-0.59858b0/lib/X11\" -I/gnu/store/cm3gmdiv2dmwnld2v5zngc5amsaxnf2b-freetype-2.13.0/include/freetype2 -I/gnu/store/1dlwzyjk51xbn1k7v7b010gidrxxvida-libpng-1.6.39/include/libpng16 -I/gnu/store/cm3gmdiv2dmwnld2v5zngc5amsaxnf2b-freetype-2.13.0/include/freetype2 -I/gnu/store/1dlwzyjk51xbn1k7v7b010gidrxxvida-libpng-1.6.39/include/libpng16 -g -O2 -Wall -g -fno-strict-aliasing -Wno-unused -Wno-comment -I/gnu/store/cm3gmdiv2dmwnld2v5zngc5amsaxnf2b-freetype-2.13.0/include/freetype2 -I/gnu/store/1dlwzyjk51xbn1k7v7b010gidrxxvida-libpng-1.6.39/include/libpng16 -MT DrawUtils.lo -MD -MP -MF .deps/DrawUtils.Tpo -c DrawUtils.c  -fPIC -DPIC -o .libs/DrawUtils.o
In file included from TabStack.c:43:
TabStack.c: In function ‘QueryGeometry’:
../Xm/TabStackP.h:140:66: error: passing argument 1 of ‘_XmTabBoxStackedGeometry’ from incompatible pointer type [-Wincompatible-pointer-types]
  140 | #define XmTabStack_tab_box(w) (((XmTabStackWidget)(w))->tab_stack.tab_box)
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
      |                                                                  |
      |                                                                  Widget {aka struct _WidgetRec *}
TabStack.c:1641:42: note: in expansion of macro ‘XmTabStack_tab_box’
 1641 |                 _XmTabBoxStackedGeometry(XmTabStack_tab_box(tab), width,
      |                                          ^~~~~~~~~~~~~~~~~~
TabStack.c:74:45: note: expected ‘XmTabBoxWidget’ {aka ‘struct _XmTabBoxRec *’} but argument is of type ‘Widget’ {aka ‘struct _WidgetRec *’}
   74 | extern void _XmTabBoxStackedGeometry _ARGS((XmTabBoxWidget, int, XRectangle *));
      |                                             ^~~~~~~~~~~~~~
TabStack.c:60:18: note: in definition of macro ‘_ARGS’
   60 | #define _ARGS(a) a
      |                  ^
--8<---------------cut here---------------end--------------->8---

I tried to build with ‘-std=c99’ (which is supposedly lower than the
default for GCC 14) but that didn’t help.

We could also check what other distros are doing.

Ludo’.

Add missing includes.

diff --git a/lib/Xm/XpmI.h b/lib/Xm/XpmI.h
index 5d690fa1..61767865 100644
--- a/lib/Xm/XpmI.h
+++ b/lib/Xm/XpmI.h
@@ -401,6 +401,7 @@ FUNC(xpmstrdup, char *, (char *s1));
 #else
 #undef xpmstrdup
 #define xpmstrdup strdup
+#include <string.h>
 #endif
 
 #ifdef NEED_STRCASECMP                   
@@ -408,6 +409,7 @@ FUNC(xpmstrcasecmp, int, (char *s1, char *s2));
 #else
 #undef xpmstrcasecmp
 #define xpmstrcasecmp strcasecmp
+#include <strings.h>
 #endif
 
 FUNC(xpmatoui, unsigned int,