Missing ZFS headers?

Hey,

I'm writing this program which relies on libzfs.h (which is indeed installed on a base FreeBSD 13/14 system, in /usr/include/). But when compiling, it fails to find some headers (which indeed aren't installed on a base FreeBSD 13/14 system). They are the following:

Code:
libnvpair.h        (from sys/contrib/openzfs/include/libnvpair.h)
ucred.h            (from sys/contrib/openzfs/lib/libspl/include/ucred.h)
sys/avl_impl.h     (from sys/contrib/openzfs/lib/libspl/include/sys/avl_impl.h)
sys/avl.h          (from sys/contrib/openzfs/lib/libspl/include/sys/avl.h)
sys/zio_priority.h (from sys/contrib/openzfs/lib/libspl/include/sys/zio_priority.h)
sys/fs/zfs.h       (from sys/contrib/openzfs/lib/libspl/include/sys/fs/zfs.h)
sys/varargs.h      (from sys/contrib/openzfs/lib/libspl/include/sys/varargs.h)
sys/mnttab.h       (from sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/mnttab.h)

Copying these files manually to /usr/include/ allows my program to compile and function perfectly.

What gives? Is this behaviour to be expected? I find it hard to imagine something that's installed on a regular FreeBSD system (libzfs.h) has some broken dependencies, so maybe I'm missing something here...
 
you need kernel source to be installed
even ports like lsof which is a userland program needs that
Indeed, I wasn't under the impression having the sources installed had anything to do with that. Do you happen to know why that is, and why then libzfs.h is included even on systems with no /usr/src?
 
Libzfs.h got into 'base' because of openzfs. It's not designed to be used, really, as it changes all the time, so the next time you compile after an OS upgrade it will probably fail. Use libzfs_core, this is the intended market for it (no need for kernel source to be pulled in, that is)

This came up in the mailing lists, but I can't find it.
 
Alrighty, makes sense to me. Appreciate the answer!

Although I will say that libzfs_core.h also includes libnvpair.h, which isn't present in base.
 
Well that seems like a genuine issue, however, I think it's just a case of nowadays programming with zfs means pulling in /usr/src. The advice still remains with libzfs_core though. Personally I don't like the idea of having to grab /usr/src though. It's bad[tm] but alas probably unavoidable.

P.S. Back in 2016 it was integrated: https://reviews.freebsd.org/rS307131 (pre-OpenZOL or whatever it's called now)

So, this seems like a bug.
 
Back
Top