Skip to content

Add optional shared library build - #5

Closed
BoatsMcGee wants to merge 2 commits into
halidecx:mainfrom
BoatsMcGee:add-windows-shared-build
Closed

BoatsMcGee wants to merge 2 commits into
halidecx:mainfrom
BoatsMcGee:add-windows-shared-build

Conversation

@BoatsMcGee

Copy link
Copy Markdown
  • Add -Dshared=true option to additionally output a shared library (.so, .dll, .dylib).
  • Add fmetrics.def to define what the Windows DLL exports.
  • Patches fcvvdp to fix building on Windows. The patch was made by an LLM so I will not be making a PR for it unless someone more knowledgeable about the codebase determines it is good. Assuming that happens I recommend updating to whatever version has that change and deleting the patch.
  • Updated README with instructions for building on Windows as it requires patching before running the build.

I built the CLI and ran it on a png and a y4m - both compared to themselves as a smoke test:

fmetrics.exe ssimu2 .\sample.y4m .\sample.y4m
fmetrics by Halide Compression, LLC | 0.1.0
99.977191

Thanks,
- Boats M.

Add Windows support patch and build
A patch is data applied to files whose line endings are fixed by whoever
fetched them. With core.autocrlf=true the working copy was rewritten to CRLF,
and git apply then failed with 'patch does not apply' because the context no
longer matched the LF cvvdp.c that Zig extracts.

Marking *.patch -text stops git converting it, so the file is committed and
checked out byte for byte.
@gianni-rosato

gianni-rosato commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Hi @BoatsMcGee,

Thanks for the change! Can you resolve the merge conflicts, address the comments, and refresh your PR?

#include <math.h>
#include <unistd.h>

+#ifdef _WIN32

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Via the README:

Compilation requires Zig ≥0.17.0 & a macOS, Linux, or Unix-like operating system.

Windows is explicitly unsupported and will not be supported officially at any point, sorry – I maintain this stance because I do not have Windows hardware and can't guarantee Windows as a first-class support target. Thus this file can be removed.

Comment thread src/fmetrics.def
@@ -0,0 +1,36 @@
; Windows module definition for the optional shared library (-Dshared=true).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Via the README:

Compilation requires Zig ≥0.17.0 & a macOS, Linux, or Unix-like operating system.

Windows is explicitly unsupported and will not be supported officially at any point, sorry – I maintain this stance because I do not have Windows hardware and can't guarantee Windows as a first-class support target. Thus this file can be removed.

Comment thread .gitattributes
@@ -0,0 +1,5 @@
# Patch files are data, not source: they are applied to files whose line

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Via the README:

Compilation requires Zig ≥0.17.0 & a macOS, Linux, or Unix-like operating system.

Windows is explicitly unsupported and will not be supported officially at any point, sorry – I maintain this stance because I do not have Windows hardware and can't guarantee Windows as a first-class support target. This file is only useful for the Windows support patch, thus this file can be removed.

Comment thread build.zig
const optimize = b.standardOptimizeOption(.{});
const strip = b.option(bool, "strip", "strip symbols from the binary, defaults to false") orelse false;
const flto = b.option(bool, "flto", "enable Link Time Optimization, defaults to false") orelse false;
const shared = b.option(bool, "shared", "also build and install a shared library (.dll/.so/.dylib), defaults to false") orelse false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove .dll – see previous comments.

Comment thread build.zig
}),
});
shared_lib.root_module.linkLibrary(lib);
// Only Windows needs an explicit export list; a DLL there exports

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove everything here related to Windows, and clean up the comments – there are far too many comments in here.

Comment thread README.md
Compilation requires [Zig](https://ziglang.org/) ≥0.16.0 & a macOS, Linux, or
Unix-like operating system. To compile, run:
Compilation requires [Zig](https://ziglang.org/) ≥0.16.0. macOS, Linux, and
Windows are supported; Windows needs one extra step, described below. To

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows not supported.

@BoatsMcGee

Copy link
Copy Markdown
Author

I'm afraid I need to preserve the changes for Windows in order to support users of my applications and outputting a shared library build was merely a means to that end so I will not be removing them. However, you have my permission to extract and use the handful of changed/added lines in build.zig to output a shared object for Unix should you need it.

Thank you,
- Boats M.

@BoatsMcGee BoatsMcGee closed this Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants