This repository contains OCaml bindings for the GTK toolkit version 4
This repository is organized to support development of GTK 4 bindings:
lablgtk/
├── conf-gtk4/ # GTK 4 stub package
├── ocgtk/ # GTK 4 bindings (under active development)
Status: 🚧 Under active development
Location: ocgtk/
Documentation: See ocgtk/README.md
The bindings are under active development and rapidly approaching a stable release.
The following features are currently supported:
- Code generation from GIR files
- Bindings for GTK and its dependencies (GLib, GObject, Pango, Gdk, GdkPixbuf, GIO)
- Support for classes, records, enumerations and bitfields
- Constructors, methods, properties and signals^[1]
- Direct C bindings and stubs ("Layer 1")
- OCaml-based class wrappers for GObject-based classes and records ("Layer 2")
Currently unsupported features:
- No support for interfaces (and methods/properties/constructors that take them as parameters)
- Signals with multiple parameters
- Functions
- Accessing fields of non-opaque record types
- Callbacks
^[1]: Only signals with no parameters are currently supported.
cd ocgtk
opam install . --deps-only
dune buildlablgtk is a GTK 3 bindings library for OCaml which served as the inspiration and some of the basis for this project. The main difference is that ocgtk uses generated bindings instead of manually written bindings. Although efforts have been made to generate code in a similar style, the APIs are different and not compatible.
- OCaml >= 4.09
- GTK 4 >= 4.10
- Cairo 2
- Dune >= 3.0
Copyright (C) 2025 Chris Armstrong, with some parts derived from lablgtk3 (see LICENSE).
This library is distributed under the terms of the GNU Library General Public License v2, with the special exception on linking described in the LICENSE file.
📚 Architecture - architecture and design documentation (mix of LLM and manually written)
- Development Setup: SETUP.md
- Security Guidelines: SECURITY_GUIDELINES.md
- GIR Code Generation: ocgtk/src/tools/README_GIR_GEN.md