High-level Lua interface
To use this package, run the following command in your project's root directory:
Put the following dependency into your project's dependences section:
LuaD - Lua for the D Programming Language
auto lua = new LuaState;
auto print = lua.get!LuaFunction("print");
LuaD is a bridge between the D and Lua programming languages. Unlike many other libraries built on the Lua C API, LuaD doesn't expose the Lua stack - instead, it has wrappers for references to Lua objects, and supports seamlessly and directly converting any D type into a Lua type and vice versa. This makes it very easy to use and encourages a much less error-prone style of programming, as well as boosting productivity by a substantial order. Due to D's powerful generic programming capabilities, performance remains the same as the equivalent using the C API.
LuaD also includes bindings for the Lua C API. To use it, import the module
luad.c.all or selectively import the modules in the
luad.c package. Usage is identical to that of working with the Lua C API. Documentation for the C API can be found here.
(LuaD currently supports Lua version 5.1)
Current progress noted in parentheses:
- Run Lua code from D, and D code from Lua (Yes)
- Support automatic conversions between any D type and its Lua equivalent (Yes)
- Support automatic conversions between D classes and Lua userdata (Partial)
- Provide access to the entire underlying Lua C API (Yes)
- Support Lua 5.2 (Not yet)
luad- the LuaD package.
visuald- VisualD project files.
test- unittest executable (when built).
lib- LuaD library files (when built).
example- LuaD examples.
The examples can be tested by running
dub run in the example's
directory (see also the examples' readme).
A tutorial can be found on the project's Wiki.
luad.all module in your project, and compile all the files in the
luad.conversions packages. You can also compile the LuaD packages to a static libary, but you still need the full LuaD sources available at compile-time due to heavy use of templates. You must also link Lua version 5.1; on Unix-like systems, the library is typically called
liblua5.1.a or similar. On Windows, you need a
lua51.lib in OMF format to be linkable with DMD.
Check out the binaries branch for a
lua51.lib import library and download instructions for a DMD-compatible library for Unix-like systems. Since the provided
lua51.lib is only an import library, you also need the Lua DLLs at runtime (which can be found here).
Please report bugs and issues to the [Github issue tracker](https://github.com/JakobOvrum/LuaD/issues). Thanks!
Build with Make
MODEL variable should be either
64 depending on whether you want to make a 32 bit or 64 bit build. It defaults to
BUILD variable controls the build configuration; it can be
release will build
lib/libluad.a in debug and release mode respectively. The
test configuration will build
test/luad_unittest and then run it with
gdb. Additionally, code coverage files (*.lst) are generated. The
BUILD variable defaults to
For example, if you want to build and run the unit tests on a 32 bit machine, the command would be:
make MODEL=32 BUILD=test
Build with VisualD/Windows
VisualD project files are included in the
visuald subdirectory. The Release and Debug configurations produce
lib/luad-d.lib respectively. The Unittest configuration produces
Project files for the examples can be found in
visuald/examples and produce binaries in the
The location of
lua51.lib needs to be configured for the LuaD Unittest configuration as well as for the examples. The projects are pre-configured to
%LUA_OMFLIB%/lua51.lib; either add the
LUA_OMFLIB environment variable, or edit the linker settings manually.
lua51.lib in OMF format can be found on the binaries branch.
LuaD is licensed under the terms of the MIT license (see the LICENSE file for details).
- Registered by JakobOvrum
- ~master released 8 years ago
- Copyright© Jakob Ovrum 2010-2014