# Missing ZFS headers?



## obiwac (Oct 24, 2021)

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:


```
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...


----------



## m0nkey_ (Oct 25, 2021)

Have you downloaded the FreeBSD source into /usr/src?









						Chapter 25. Updating and Upgrading FreeBSD
					

Information about how to keep a FreeBSD system up-to-date with freebsd-update or Git, how to rebuild and reinstall the entire base system, etc




					docs.freebsd.org


----------



## obiwac (Oct 25, 2021)

Yes, but that should be irrelevant I believe


----------



## covacat (Oct 25, 2021)

you need kernel source to be installed 
even ports like lsof which is a userland program needs that


----------



## obiwac (Oct 25, 2021)

covacat said:


> 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?


----------



## mark_j (Oct 25, 2021)

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.


----------



## obiwac (Oct 25, 2021)

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.


----------



## mark_j (Oct 25, 2021)

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.


----------

