Solved Build error for dwm

Hi daemons,

I'm trying to give a try to a fork of dwm.suckless port.


Bash:
dwm.c:2406:28: warning: implicit declaration of function
      'kinfo_getproc' is invalid in C99
      [-Wimplicit-function-declaration]
        struct kinfo_proc *proc = kinfo_getproc(p);
                                  ^
dwm.c:2406:21: warning: incompatible integer to pointer
      conversion initializing 'struct kinfo_proc *' with an
      expression of type 'int' [-Wint-conversion]
        struct kinfo_proc *proc = kinfo_getproc(p);
                           ^      ~~~~~~~~~~~~~~~~
dwm.c:2410:10: error: incomplete definition of type
      'struct kinfo_proc'
        v = proc->ki_ppid;
            ~~~~^
dwm.c:2406:9: note: forward declaration of
      'struct kinfo_proc'
        struct kinfo_proc *proc = kinfo_getproc(p);
               ^
2 warnings and 1 error generated.
*** Error code 1

Checking more at the sources it's trying to get the parent process specifically for FreeBSD(source):


C:
#elif defined(__FreeBSD__)
    struct kinfo_proc *proc = kinfo_getproc(p);
    if (!proc)
        return (pid_t)0;

    v = proc->ki_ppid;
    free(proc);
#endif
    return (pid_t)v;
}

How can I solve this? or at least any help is welcome.
 
Checking more at the sources it's trying to get the parent process specifically for FreeBSD(source):

Luke Smith's fork is for Linux -- I think he's using artix. Keep that in mind.
Therefore you are better off to use the original upstream from the Suckless,
Make necessary changes to config.mk, in order to set it to work on FreeBSD


Code:
X11INC = /usr/local/include
X11LIB = /usr/local/lib
FREETYPEINC = /usr/local/include/freetype2

Then, use whatever patch and/or custom config.def.h from the Luke Smith's fork.
That's much easier IMHO!
 
Well, I got it already working from suckless and with same changes you commented but, I wanted to experience that fork. I removed that condition and it built but, I'm not satisfy to do that without knowing exactly what I'm doing.
 
It sounds as if the OP isn't building from the port, but rather from an upstream fork. I always use the port and just put whatever patches I want applied into /usr/ports/x11-wm/dwm/files.
 
  • Thanks
Reactions: a6h
How did you build the port upstream fork [*]? Please post the command line.

[*]/[EDIT] Thanks scottro
I do just: `make clean install`

I added to the end


Makefile:
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lutil


And, in the dwm.c I tried with two set of headers:

C:
#include <sys/types.h>
#include <sys/user.h>
#include <sys/sysctl.h>

and
C:
#include <sys/libutil.h>


The only library that makes a different output error is `sys/user.h`.


Thank you for the help !!
 
This is the error with the <sys/user.h>

Code:
rm -f dwm drw.o dwm.o util.o dwm-6.2.tar.gz *.orig *.rej
dwm build options:
CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/local/include -I/usr/local/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION="6.2" -DXINERAMA
LDFLAGS  = -L/usr/local/lib -lX11 -lXinerama -lfontconfig -lXft -lX11-xcb -lxcb -lxcb-res -lutil
CC       = cc
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/local/include -I/usr/local/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"6.2\" -DXINERAMA drw.c
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/local/include -I/usr/local/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"6.2\" -DXINERAMA dwm.c
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:40:
/usr/include/machine/pcb.h:81:2: error: unknown type name 'u_int'
        u_int           pcb_flags;
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:46:
/usr/include/sys/ucred.h:86:2: error: unknown type name 'u_int'
        u_int   cr_version;             /* structure layout version */
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:49:
/usr/include/sys/_lock.h:38:2: error: unknown type name 'u_int'
        u_int   lo_flags;
        ^
/usr/include/sys/_lock.h:39:2: error: unknown type name 'u_int'
        u_int   lo_data;                /* General class specific data. */
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:47:
In file included from /usr/include/sys/filedesc.h:41:
/usr/include/sys/lock.h:63:2: error: unknown type name 'u_int'
        u_int           lc_flags;
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:47:
In file included from /usr/include/sys/filedesc.h:42:
/usr/include/sys/priority.h:129:2: error: unknown type name 'u_char'; did you mean 'char'?
        u_char  pri_class;      /* Scheduling class. */
        ^
/usr/include/sys/priority.h:130:2: error: unknown type name 'u_char'; did you mean 'char'?
        u_char  pri_level;      /* Normal priority level. */
        ^
/usr/include/sys/priority.h:131:2: error: unknown type name 'u_char'; did you mean 'char'?
        u_char  pri_native;     /* Priority before propagation. */
        ^
/usr/include/sys/priority.h:132:2: error: unknown type name 'u_char'; did you mean 'char'?
        u_char  pri_user;       /* User priority based on p_cpu and p_nice. */
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:47:
/usr/include/sys/filedesc.h:50:2: error: unknown type name 'u_long'; did you mean 'long'?
        u_long          *fc_ioctls;     /* per-descriptor allowed ioctls */
        ^
/usr/include/sys/filedesc.h:84:2: error: unknown type name 'u_long'; did you mean 'long'?
        NDSLOTTYPE *fd_map;             /* bitmap of free fds */
        ^
/usr/include/sys/filedesc.h:77:20: note: expanded from macro 'NDSLOTTYPE'
#define NDSLOTTYPE      u_long
                        ^
/usr/include/sys/filedesc.h:87:2: error: unknown type name 'u_short'; did you mean 'short'?
        u_short fd_cmask;               /* mask for file creation */
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:53:
/usr/include/sys/osd.h:42:2: error: unknown type name 'u_int'
        u_int             osd_nslots;   /* (c) */
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:55:
/usr/include/sys/rtprio.h:76:2: error: unknown type name 'u_short'; did you mean 'short'?
        u_short type;                   /* scheduling class */
        ^
/usr/include/sys/rtprio.h:77:2: error: unknown type name 'u_short'; did you mean 'short'?
        u_short prio;
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:56:
/usr/include/sys/runq.h:75:54: error: unknown type name 'u_char'; did you mean 'char'?
void    runq_remove_idx(struct runq *, struct thread *, u_char *);
                                                        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:60:
/usr/include/sys/signalvar.h:55:2: error: unknown type name 'sig_t'
        sig_t   ps_sigact[_SIG_MAXSIG]; /* Disposition of signals. */
        ^
/usr/include/sys/signalvar.h:68:2: error: unknown type name 'u_int'
        u_int   ps_refcnt;
        ^
In file included from dwm.c:33:
In file included from /usr/include/sys/user.h:51:
In file included from /usr/include/sys/proc.h:72:
/usr/include/machine/proc.h:56:2: error: unknown type name 'u_long'; did you mean 'long'?
        u_long gen;                     /* (k) */
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
*** Error code 1
 
s0undsp4c3
1. Does your build have libxft-bgra problem or you've fixed it?
2. Are you using Luke Smith st fork, or your own?
3. If you're going to put it on public repo, post the link too. Thanks.
 
s0undsp4c3
1. Does your build have libxft-bgra problem or you've fixed it?
2. Are you using Luke Smith st fork, or your own?
3. If you're going to put it on public repo, post the link too. Thanks.
vigole

1. Didn't have problem with libxft-bgra. No not at all.
2. I'm using st terminal from luke smith but, dwm no yet.
3. I didn't do that but, I can do it if you want.

These are the changes I did.


Diff:
diff --git a/config.mk b/config.mk
index b77641d..3ffc92b 100644
--- a/config.mk
+++ b/config.mk
@@ -7,8 +7,11 @@ VERSION = 6.2
 PREFIX = /usr/local
 MANPREFIX = ${PREFIX}/share/man

-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+#X11INC = /usr/X11R6/include
+#X11LIB = /usr/X11R6/lib
+X11INC = /usr/local/include
+X11LIB = /usr/local/lib
+

 # Xinerama, comment if you don't want it
 XINERAMALIBS  = -lXinerama
@@ -16,18 +19,20 @@ XINERAMAFLAGS = -DXINERAMA

 # freetype
 FREETYPELIBS = -lfontconfig -lXft
-FREETYPEINC = /usr/include/freetype2
+#FREETYPEINC = /usr/include/freetype2
+FREETYPEINC = /usr/local/include/freetype2
+
 # OpenBSD (uncomment)
 #FREETYPEINC = ${X11INC}/freetype2

 # includes and libs
 INCS = -I${X11INC} -I${FREETYPEINC}
-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res
+LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res -lutil

 # flags
-CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
 #CFLAGS   = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
-CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
+CFLAGS   =  -std=gnu99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
 LDFLAGS  = ${LIBS}

 # Solaris
diff --git a/dwm.c b/dwm.c
index 929f878..63d8b7e 100644
--- a/dwm.c
+++ b/dwm.c
@@ -30,6 +30,8 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/user.h>
+#include <sys/sysctl.h>
 #include <X11/cursorfont.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
 
Back
Top