Dynamic Lua binding to GObject libraries using GObject-Introspection
Lua
492
1,336 commits
updated Aug 17, 2026
LGI is gobject-introspection based dynamic Lua binding to GObject based libraries. It allows using GObject-based libraries directly from Lua.
Licensed under MIT-style license, see LICENSE file for full text.
Home of the project is on GitHub.
LGI is tested and compatible with standard Lua 5.1, Lua 5.2, Lua 5.3 and LuaJIT2. Compatibility with other Lua implementations is not tested yet. Lua 5.4 is only supported experimentally.
If you need to support pre-gobject-introspection GTK (ancient GTK+ 2.x releases), use Lua-Gnome.
In order to be able to compile native part of lgi,
gobject-introspection >= 0.10.8 development package must be installed,
although preferred version is >= 1.30. The development package is
called libgirepository1.0-dev on debian-based systems (like Ubuntu)
and gobject-introspection-devel on RedHat-based systems (like Fedora).
Using LuaRocks:
luarocks install lgi
Alternatively, use make-based installation:
make
[sudo] make install [PREFIX=<prefix>] [DESTDIR=<destdir>]
Please note that on BSD-systems you may need to use 'gmake'.
Building via Meson is also supported, with the same requirements, plus a Meson installation along with the Ninja build tool, in an empty build directory:
cd $(builddir)
meson $(lgi_srcroot) [--prefix=<prefix>] [--buildtype=<buildtype>] [--pkg-config-path=<pkgconfigpath>] [-Dlua-pc=...] [-Dlua-bin=...]
ninja
ninja test
[sudo] ninja install
Building lgi with Visual Studio 2013 and later is also supported via
Meson. It is recommended in this case that CMake is also installed to
make finding Lua or LuaJIT easier, since Lua and LuaJIT support Visual
Studio builds via batch files or manual compilation of sources. Ensure
that %INCLUDE% includes the path to the Lua or LuaJIT headers, and
%LIB% includes the path where the lua5x.lib from Lua or LuaJIT can be
found, and ensure that lua5x.dll and lua.exe or luajit.exe can be
found in %PATH% and run correctly. For building with LuaJIT, please do
not pass in -Dlua-pc=luajit, but do pass in -Dlua-bin=luajit in the
Meson command line so that the LuaJIT interpreter can be found correctly.
See examples in samples/ directory. Documentation is available in
doc/ directory in markdown format. Process it with your favorite
Markdown processor if you want to read it in HTML. You can also check
the moonsteal/lua-gtk-examples repository, where you can find a variety
of Lua Gtk examples.
List of contributors, in no particular order:
Many other people contributed to what lgi is today, in many forms - writing patches, reporting bugs, packaging for distributions, providing ideas, spreading a word... Many thanks to all of you!
CFLAGS and LDFLAGS env vars valuesset_resident() more robust and fix stack leak for Lua 5.2 case,
avoid useless warning when set_resident() fails (to accommodate for
static linking case).lua_State using lgi._type property as documentedContext:user_to_device() family of methods.Gtk.Builder:connect_signals() overridebyte.buffer when UTF8 string is requested.GType into lua_Number any more; this could
cause crashes on some 64bit arches.docs/gtk.lua, chapter about Gtk.Container for overview and
samples.waf to simple Makefile-based oneGdk.threads_enter(),
Gdk.threads_leave() and Clutter.threads_enter(),
Clutter.threads_leave() pairs into application, lgi handles this
automatically.samples/console.lua, which implements already
quite usable Lua console using Gtk widgets.setlocale() initialization, which could break Lua when used
with some regional locales. The downside of this change is that
marshaling file names containing non-ASCII characters on systems
which define G_BROKEN_FILENAMES environment variable (probably
only Fedora 15) does not work now.First public release
(top 30 of 38)
Lua
60.8%
C
37.2%
Makefile
1.1%
Dynamic Lua binding to GObject libraries using GObject-Introspection
Lua
492
1,336 commits
updated Aug 17, 2026
LGI is gobject-introspection based dynamic Lua binding to GObject based libraries. It allows using GObject-based libraries directly from Lua.
Licensed under MIT-style license, see LICENSE file for full text.
Home of the project is on GitHub.
LGI is tested and compatible with standard Lua 5.1, Lua 5.2, Lua 5.3 and LuaJIT2. Compatibility with other Lua implementations is not tested yet. Lua 5.4 is only supported experimentally.
If you need to support pre-gobject-introspection GTK (ancient GTK+ 2.x releases), use Lua-Gnome.
In order to be able to compile native part of lgi,
gobject-introspection >= 0.10.8 development package must be installed,
although preferred version is >= 1.30. The development package is
called libgirepository1.0-dev on debian-based systems (like Ubuntu)
and gobject-introspection-devel on RedHat-based systems (like Fedora).
Using LuaRocks:
luarocks install lgi
Alternatively, use make-based installation:
make
[sudo] make install [PREFIX=<prefix>] [DESTDIR=<destdir>]
Please note that on BSD-systems you may need to use 'gmake'.
Building via Meson is also supported, with the same requirements, plus a Meson installation along with the Ninja build tool, in an empty build directory:
cd $(builddir)
meson $(lgi_srcroot) [--prefix=<prefix>] [--buildtype=<buildtype>] [--pkg-config-path=<pkgconfigpath>] [-Dlua-pc=...] [-Dlua-bin=...]
ninja
ninja test
[sudo] ninja install
Building lgi with Visual Studio 2013 and later is also supported via
Meson. It is recommended in this case that CMake is also installed to
make finding Lua or LuaJIT easier, since Lua and LuaJIT support Visual
Studio builds via batch files or manual compilation of sources. Ensure
that %INCLUDE% includes the path to the Lua or LuaJIT headers, and
%LIB% includes the path where the lua5x.lib from Lua or LuaJIT can be
found, and ensure that lua5x.dll and lua.exe or luajit.exe can be
found in %PATH% and run correctly. For building with LuaJIT, please do
not pass in -Dlua-pc=luajit, but do pass in -Dlua-bin=luajit in the
Meson command line so that the LuaJIT interpreter can be found correctly.
See examples in samples/ directory. Documentation is available in
doc/ directory in markdown format. Process it with your favorite
Markdown processor if you want to read it in HTML. You can also check
the moonsteal/lua-gtk-examples repository, where you can find a variety
of Lua Gtk examples.
List of contributors, in no particular order:
Many other people contributed to what lgi is today, in many forms - writing patches, reporting bugs, packaging for distributions, providing ideas, spreading a word... Many thanks to all of you!
CFLAGS and LDFLAGS env vars valuesset_resident() more robust and fix stack leak for Lua 5.2 case,
avoid useless warning when set_resident() fails (to accommodate for
static linking case).lua_State using lgi._type property as documentedContext:user_to_device() family of methods.Gtk.Builder:connect_signals() overridebyte.buffer when UTF8 string is requested.GType into lua_Number any more; this could
cause crashes on some 64bit arches.docs/gtk.lua, chapter about Gtk.Container for overview and
samples.waf to simple Makefile-based oneGdk.threads_enter(),
Gdk.threads_leave() and Clutter.threads_enter(),
Clutter.threads_leave() pairs into application, lgi handles this
automatically.samples/console.lua, which implements already
quite usable Lua console using Gtk widgets.setlocale() initialization, which could break Lua when used
with some regional locales. The downside of this change is that
marshaling file names containing non-ASCII characters on systems
which define G_BROKEN_FILENAMES environment variable (probably
only Fedora 15) does not work now.First public release
(top 30 of 38)
Lua
60.8%
C
37.2%
Makefile
1.1%