libghostty-vt 0.0.0
Loading...
Searching...
No Matches
Installing

libghostty-vt is a normal C library. There are several official ways to get it:

We don't publish prebuilt packages for Linux, FreeBSD or Windows. On those systems, you build from source or use your system's package if it has one.

Every method that builds the library needs Zig 0.17. You don't need to know any Zig to do it. The build stops with an error on any other minor version. Different libghostty-vt versions may require different Zig versions, the Zig version is not part of our ABI promise.

Release Files

libghostty-vt is released separately from Ghostty, with its own version numbers and its own vt-X.Y.Z tags. Each release is published to one directory:

https://release.files.ghostty.org/libghostty-vt/VERSION/

VERSION is the version number with no prefix, such as 0.1.0. The directory has the following files:

File Contents
libghostty-vt-VERSION.tar.gz Source tarball
libghostty-vt-VERSION-deps.tar.gz Zig packages for building with no network
libghostty-vt-VERSION-docs.zip This documentation as HTML
ghostty-vt-VERSION.xcframework.zip Static libraries for macOS and iOS
ghostty-vt-VERSION.wasm WebAssembly module, optimized for speed
ghostty-vt-VERSION-small.wasm WebAssembly module, optimized for size
SHA256SUMS Checksums of all of the above

Verifying a download: every file has a minisign signature next to it, with a .minisig extension. Check SHA256SUMS against our public key, then check your files against SHA256SUMS:

minisign -V -P RWQlAjJC23149WL2sEpT/l0QKy7hMIFhYdQOFy0Z7z7PbneUgvlsnYcV -m SHA256SUMS
sha256sum --ignore-missing -c SHA256SUMS

Trying unreleased code: the tip release has a source tarball, an XCFramework and the WebAssembly modules built from the latest commit to main. They change with every commit, so don't ship them.

Swift and Apple Platforms

The XCFramework has static libraries for macOS (arm64 and x86_64), iOS, and the iOS simulator, along with the headers and a module map. Add it to your package as a binaryTarget:

.binaryTarget(
name: "GhosttyVt",
url: "https://release.files.ghostty.org/libghostty-vt/0.1.0/ghostty-vt-0.1.0.xcframework.zip",
checksum: "<sha256 of the zip>"
),

The checksum is the line for the zip in SHA256SUMS. Depend on GhosttyVt from your target, then import GhosttyVt to call the C API from Swift. In an Xcode project, unzip it and add ghostty-vt.xcframework to your target instead.

To build it yourself, run this from a checkout on a Mac with Xcode to get zig-out/lib/ghostty-vt.xcframework:

zig build -Demit-lib-vt -Demit-xcframework=true -Doptimize=ReleaseFast

See swift-vt-xcframework for a full example.

WebAssembly

We publish two builds of the WebAssembly module, and both have every feature enabled:

  • ghostty-vt-VERSION-small.wasm: optimized for size. Use this one on the web unless you've measured a reason not to.
  • ghostty-vt-VERSION.wasm: optimized for speed. It's 10-20% faster on workloads heavy in escape sequences, and somewhat larger.

To build it yourself, for example to leave out features and make it smaller, run this from a checkout to get zig-out/bin/ghostty-vt.wasm:

zig build -Demit-lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall

See wasm-vt for how to load it from JavaScript, and WebAssembly for the functions that only exist for this build.

CMake

CMake can fetch and build the library for you, so you can skip the build below. You still need zig on your PATH.

include(FetchContent)
FetchContent_Declare(ghostty
URL https://release.files.ghostty.org/libghostty-vt/0.1.0/libghostty-vt-0.1.0.tar.gz
URL_HASH SHA256=<sha256 of the tarball>
)
FetchContent_MakeAvailable(ghostty)
add_executable(hello hello.c)
target_link_libraries(hello PRIVATE ghostty-vt)

The hash is the line for the tarball in SHA256SUMS. Link ghostty-vt-static instead for the static library.

If you already installed the library, use find_package(ghostty-vt REQUIRED) and link ghostty-vt::ghostty-vt. Pass -DCMAKE_PREFIX_PATH="$HOME/.local" if CMake can't find it.

See c-vt-cmake and c-vt-cmake-static. To cross-compile, see c-vt-cmake-cross and the CMake README.

Zig

Zig programs can use the Zig module directly, which skips the C API:

zig fetch --save=ghostty https://release.files.ghostty.org/libghostty-vt/0.1.0/libghostty-vt-0.1.0.tar.gz

Then import the module in your build.zig:

if (b.lazyDependency("ghostty", .{})) |dep| {
exe_mod.addImport("ghostty-vt", dep.module("ghostty-vt"));
}

See zig-vt. If your Zig build compiles a C program, use exe_mod.linkLibrary(dep.artifact("ghostty-vt")) instead, as c-vt-stream does.

Nix

Our flake has a libghostty-vt package, built with ReleaseFast:

nix build 'github:ghostty-org/ghostty/vt-0.1.0#libghostty-vt^*'

The ^* builds every output. The default output has the shared library, and the dev output has the headers, the static library, and the pkg-config and CMake files.

Build from Source

Download a source tarball and build it:

curl -LO https://release.files.ghostty.org/libghostty-vt/0.1.0/libghostty-vt-0.1.0.tar.gz
tar -xzf libghostty-vt-0.1.0.tar.gz
cd libghostty-vt-0.1.0
zig build -Doptimize=ReleaseFast --prefix "$HOME/.local"

This installs the shared library, the static library, the headers, and the pkg-config and CMake files.

Use the release tarball, not the archive GitHub generates for a tag. The GitHub archive is missing the file that tells the build to make the library, so it builds the Ghostty app instead.

From a checkout: to build main or any other commit, add -Demit-lib-vt. Without it, zig build builds the Ghostty app.

git clone https://github.com/ghostty-org/ghostty
cd ghostty
zig build -Demit-lib-vt -Doptimize=ReleaseFast --prefix "$HOME/.local"

With no network: the build downloads a few Zig packages. The dependency tarball has all of them, and the packaging guide shows how to use it. If you're packaging libghostty-vt for a distribution, start there.

pkg-config

Save the program from the main page as hello.c and build it:

export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig"
cc -o hello hello.c $(pkg-config --cflags --libs libghostty-vt) -Wl,-rpath,"$HOME/.local/lib"
./hello

The rpath tells the loader where the shared library is. On macOS you always need one, because the library loads as @rpath/libghostty-vt.0.dylib. On Linux you can drop it if you install to a directory the loader already searches, such as /usr/lib.

Static Linking

Link statically when you want one binary with nothing to install next to it:

cc -o hello hello.c $(pkg-config --static --cflags --libs libghostty-vt-static)

Build Options

Most programs don't need any of these. The packaging guide has the whole list.

-Dsimd=false removes the SIMD code. On Linux that also removes libc: the shared library then links nothing at all. It makes parsing much slower, so only do this if libc is what you're trying to avoid. WebAssembly and freestanding builds are like this already. On macOS the library still links libSystem, like every program does.

-Dvt-features leaves out parts of the library to make it smaller. See Optional Features.