Skip to content

Brewfile: libheif, because the Go binding is cgo and does not carry the codec - #84

Merged
landsman merged 2 commits into
mainfrom
brewfile-libheif
Aug 13, 2026
Merged

Brewfile: libheif, because the Go binding is cgo and does not carry the codec#84
landsman merged 2 commits into
mainfrom
brewfile-libheif

Conversation

@landsman

@landsman landsman commented Aug 13, 2026

Copy link
Copy Markdown
Owner

One line in the Brewfile, plus the comment that says why it is there.

What it is for

Go development that handles images: decoding HEIF/HEIC — the format phones now shoot by default — and rendering thumbnails from it. strukturag/libheif is the upstream, and the surprise worth writing down is that one repo holds both halves: the C library, and the Go binding under go/heif.

Why it has to be installed

make run in a work Go repo, on this Mac, with the toolchain otherwise complete:

# github.com/strukturag/libheif/go/heif
# [pkg-config --cflags  -- libheif]
Package libheif was not found in the pkg-config search path.

The Go module is a binding, not a port. Its go/heif package is cgo with #cgo pkg-config: libheif, so go build shells out to pkg-config at compile time and fails there unless the C library and its libheif.pc are already on the machine. Nothing in go.mod can fix that — go mod download fetches the wrapper and the wrapper alone.

So it belongs to the machine, next to libpq and poppler, which are here for the same reason.

Placement

Unguarded, in the portable-CLI half — homebrew-core builds libheif for x86_64_linux as well, so the Kubuntu side needs no os/ubuntu entry. Alphabetical, before libpq.

brew install libheif also pulls libde265 as a dependency; Homebrew resolves that itself, no line of its own.

Checks

make apps-test passes, and brew bundle list --file Brewfile prints libheif — so the Ruby parses and the entry is really in the list, not just in the file. After installing, pkg-config --modversion libheif1.23.1 and the build that started this gets through cgo.

Not verified: the Linux bottle, since this was done on the Mac. It is in homebrew-core's x86_64_linux bottle list, which is the same evidence every other unguarded line here rests on.

Hit on a work repo: `go run` died at `pkg-config --cflags -- libheif`,
because github.com/strukturag/libheif is a binding, not a port — the
codec itself has to be on the machine already.

Portable CLI tooling, so one unguarded line: homebrew-core builds
libheif on Linux too.
Go development: decoding HEIF/HEIC and rendering thumbnails from it.
Plus the upstream link, since one repo carries both the C library and
the cgo binding and that is the part that surprises.
@landsman
landsman merged commit 4e3f0f2 into main Aug 13, 2026
3 checks passed
@landsman
landsman deleted the brewfile-libheif branch August 13, 2026 14:46
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.

1 participant