libxml2 ported to the zig build system
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-01 21:50:14 +02:00
.github/workflows remove support for Zig nightly 2026-10-01 21:48:50 +02:00
.gitattributes initial commit 2024-12-18 19:58:52 +01:00
.gitignore libxml updated for 0.17.0-dev.389+f5a1968f6 2026-05-29 22:58:51 -07:00
build.zig remove support for Zig nightly 2026-10-01 21:48:50 +02:00
build.zig.zon update upstream to 2.15.4 2026-10-01 21:49:21 +02:00
LICENSE initial commit 2024-12-18 19:58:52 +01:00
README.md release 2.15.4 2026-10-01 21:50:14 +02:00

CI

libxml2

This is libxml2, packaged for Zig.

Installation

First, update your build.zig.zon:

# Initialize a `zig build` project if you haven't already
zig init
zig fetch --save git+https://github.com/allyourcodebase/libxml2.git#2.15.4

You can then import libxml2 in your build.zig with:

const libxml2_dependency = b.dependency("libxml2", .{
    .target = target,
    .optimize = optimize,

    // libxml2 will try to link to iconv on macOS by default which will
    // fail when cross-compiling. You may disable iconv support for or
    // link against GNU libiconv which is licensed under LGPL.

    // disable iconv support on all targets
    // .iconv = false,

    // disable iconv support when compiling to macOS
    // .iconv = !target.result.os.tag.isDarwin(),

    // disable iconv support when cross-compiling to macOS
    // .iconv = !(target.query.isNativeOs() and target.result.os.tag.isDarwin()),

    // Use GNU libiconv on macOS which is licensed under LGPL.
    // .@"iconv-impl" = @as(?enum{libc, libiconv, win_iconv}, if (target.result.os.tag.isDarwin()) .libiconv else null),
});
your_exe.root_module.linkLibrary(libxml2_dependency.artifact("xml"));