A Zig build wrapper for the ZFP C compression library
  • Zig 83.1%
  • C 16.9%
Find a file
keltonhalbert 0ed369d19b
All checks were successful
CI Build / build (ubuntu-latest) (push) Successful in 36s
added notes about freestanding
2026-06-06 15:24:45 -05:00
.forgejo/workflows added testing so that freestanding is covered by CI 2026-05-30 16:43:31 -05:00
freestanding-libc added freestanding shims for wasm32-freestanding targets 2026-05-30 15:44:16 -04:00
src/freestanding generalized target to include wasm64 2026-05-30 16:48:31 -05:00
test generalized target to include wasm64 2026-05-30 16:48:31 -05:00
.gitignore upgraded to Zig 0.16.0 2026-05-08 21:38:13 -05:00
build.zig generalized target to include wasm64 2026-05-30 16:48:31 -05:00
build.zig.zon added testing so that freestanding is covered by CI 2026-05-30 16:43:31 -05:00
LICENSE Adding license and README 2025-04-18 22:54:10 -05:00
README.md added notes about freestanding 2026-06-06 15:24:45 -05:00

Build

Zfp packaged for the Zig programming language

This is the ZFP C compression library for the Zig programming language. Currently does not wrap the C++ compressed array classes.

How do I include it in my Zig program?

If you are starting a new package:


mkdir my_project; cd my_project
zig init
## add the package to 'build.zig.zon'
zig fetch --save=zfp git+https://labs.stormscale.io/kelton.halbert/zfp.git

This will add the zig C library as a dependency to your project. Next, if you are linking it to a library or executable, add the following to build.zig:

pub fn build(b: *std.Build) !void {
    const target = b.standardTargetOptions(.{});

    const optimize = b.standardOptimizeOption(.{});

    const zfp_dep = b.dependency("zfp", .{
        .target = target,
        .optimize = optimize,
    });

    // if you are linking it to a library...
    const lib_mod = b.createModule(.{
        .root_source_file = b.path("src/root.zig"),
        .target = target,
        .optimize = optimize,
    });

    lib_mod.linkLibrary(zfp_dep.artifact("zfp"));
        
    // or, if you are linking it to an executable...
    const exe_mod = b.createModule(.{
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    exe_mod.linkLibrary(zfp_dep.artifact("zfp"));
}

Freestanding WASM

This package includes the libc shims required to build freestanding wasm targets. It currently manually specified the wasm allocator for malloc and free function calls, though later versions may require consumers of the freestanding package to provide their own malloc and free wrappers.

Requirements

The target version of Zig is 0.16.0. It may work with earlier versions, but has not been tested.