[Bug 257222] Cannot use libzfs.h from user space programs due to missing libnvpair.h and other dependencies
Date: Sun, 02 Jan 2022 16:04:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257222
--- Comment #3 from Michael Gmelin <grembo@FreeBSD.org> ---
Simple working example:
```
$ cat >test.c <<EOF
#include <sys/stdtypes.h>
#include <libzfs_core.h>
int main(int argc, char** argv)
{
if (argc != 2) {
fprintf(stderr, "Invalid arguments\n");
return 101;
}
if (libzfs_core_init() != 0) {
fprintf(stderr, "Can't init libzfs\n");
return 101;
}
int exists = lzc_exists(argv[1]);
printf("%s %s\n", argv[1],
exists ? "exists" : "doesn't exist");
libzfs_core_fini();
return exists ? 0 : 1;
}
EOF
$ cc \
-I/usr/src/sys/contrib/openzfs/include \
-I/usr/src/sys/contrib/openzfs/lib/libspl/include \
-lzfs_core -lzfs -o test test.c
$ ./test zroot
zroot exists
```
--
You are receiving this mail because:
You are the assignee for the bug.