Cannot build slstatus from source

I am trying to build slstatus on freebsd. Updated config.mk (Here's the git diff from original version https://pastebin.com/JTaCuXyq) to set the include and library paths. However, still getting the following error messages when running make: https://pastebin.com/6hbF44eA

The weird thing is sndio.h is present in /usr/local/include and was imported correctly in components/volume.c but for some reason error message states that sioctl_* (which were defined in sndio.h) is undefined. Also, the kvm_openfiles bit in components/swap.c which the code imports from kvm.h but kvm.h is not present in either of those locations. I am guessing that has to do Linux's Kernel Virtual Machine and part of libkvm? Problem is I didn't find that package from pkg search.

Should I try to build slstatus without the swap and volume components?
 
Also, the kvm_openfiles bit in components/swap.c which the code imports from kvm.h but kvm.h is not present in either of those locations.
There's a reason why that bit of code is encapsulated with a #if defined(__linux__).
 
sioctl_* looks like an openbsd proprietary thing
No this is part of the official Sndio API and is defined in /usr/local/include/sndio.h.

The weird thing is sndio.h is present in /usr/local/include and was imported correctly in components/volume.c but for some reason error message states that sioctl_* (which were defined in sndio.h) is undefined. Also, the kvm_openfiles bit in components/swap.c which the code imports from kvm.h but kvm.h is not present in either of those locations. I am guessing that has to do Linux's Kernel Virtual Machine and part of libkvm? Problem is I didn't find that package from pkg search.
Code:
ld: error: undefined symbol: sioctl_open

This is a linker error. It can't find the symbols in the provided libraries. Look into config.mk, there's actually a comment for compiling on FreeBSD:
Code:
...snip...
# FreeBSD: add -lkvm -lsndio
LDLIBS   = -lX11
...snip...

Append -lkvm -lsndio to LDLIBS.
 
Right. But that doesn't look like anything that would run/build on FreeBSD, those don't look like the correct APIs.

Code:
    190 #elif defined(__FreeBSD__)
    191 	#include <fcntl.h>
    192 	#include <kvm.h>
    193 	#include <stdlib.h>
    194 	#include <sys/types.h>
    195 	#include <unistd.h>
    196 
    197 	static int getswapinfo(struct kvm_swap *swap_info, size_t size)
    198 	{
    199 		kvm_t *kd;
    200 
    201 		kd = kvm_openfiles(NULL, "/dev/null", NULL, 0, NULL);
    202 		if (kd == NULL) {
    203 			warn("kvm_openfiles '/dev/null':");
    204 			return 0;
    205 		}
    206 
    207 		if (kvm_getswapinfo(kd, swap_info, size, 0 /* Unused flags */) < 0) {
    208 			warn("kvm_getswapinfo:");
    209 			kvm_close(kd);
    210 			return 0;
    211 		}
    212 
    213 		kvm_close(kd);
    214 		return 1;
    215 	}

Looks like somebody just added some code, slapped a __FreeBSD__ define around it but never tested the code itself.
 
Well, goes to show, I'm not a developer. They are FreeBSD APIs.

kvm_openfiles(3), kvm_getswapinfo(3)

but kvm.h is not present in either of those locations.
It lives in /usr/include because it's part of the base OS, kernel specifically, but that's also part of the OS :D (kvm(3))
Code:
% ll /usr/include/kvm.h
-r--r--r--  1 root wheel 4193 Dec  9  2023 /usr/include/kvm.h
 
Thank you all! I apologize for the obtuse error. I didn't really read the source code in depth, and I am new to FreeBSD and the FreeBSD community is amazing! I would have to wait at least 3 business days to get the answer to my question on other forums.

Just if some of the important packages weren't unmaintained on freshports, 2025 would've been the year of FreeBSD desktop!
 
Back
Top