engine/language_client_go/README_WINDOWS.md
The Go BAML client now supports Windows (x86_64 and ARM64) in addition to macOS and Linux.
The Go client requires CGO to interface with the BAML runtime library. When building on Windows:
# Build normally on Windows
go build ./...
# The library will automatically be downloaded to:
# %LOCALAPPDATA%\baml\libs\{VERSION}\baml_cffi-{target}.dll
Due to CGO requirements, cross-compiling from Unix to Windows requires a Windows cross-compiler:
# This will NOT work without a cross-compiler:
GOOS=windows go build ./...
# With a cross-compiler installed (e.g., mingw-w64):
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build ./...
Build directly on Windows for Windows binaries, on Linux for Linux binaries, etc.
The GitHub Actions workflow builds native binaries for each platform:
windows-2022 runnermacos-latest runnerubuntu-latest runnerDownload pre-built CFFI libraries from GitHub releases and set:
export BAML_LIBRARY_PATH=/path/to/baml_cffi.dll
baml_cffi-{target}.dll (no "lib" prefix)libbaml_cffi-{target}.dyliblibbaml_cffi-{target}.soWhere {target} is:
x86_64-pc-windows-msvc (Windows x64)aarch64-pc-windows-msvc (Windows ARM64)x86_64-apple-darwin (macOS Intel)aarch64-apple-darwin (macOS Apple Silicon)x86_64-unknown-linux-gnu (Linux x64)aarch64-unknown-linux-gnu (Linux ARM64)This error occurs when trying to cross-compile without CGO. Solutions:
Ensure the BAML CFFI library is available:
%LOCALAPPDATA%\baml\libs\BAML_LIBRARY_PATH environment variableThe Go package version must match the CFFI library version. Check:
const VERSION = "0.211.2" // in lib_common.go