Embedding LuaVela Using pkg-config


As of version 0.16, a pkg-config file for LuaVela is provided for easier embedding LuaVela into other programs. This short tutorial will guide you through this process.


You need to have LuaVela installed on your system to proceed.

Sample C Program

Assume we have a following file named sample.c:

#include <ujit/lua.h>
#include <ujit/lauxlib.h>

int main()
    lua_State *L = luaL_newstate();
    return 0;

Compilation and Linking

You can compile and link your program which embeds LuaVela using following commands:

$ gcc -Wall -Werror -ggdb3 `pkg-config --cflags ujit` -c sample.c -o sample.o
$ gcc -Wall -Werror sample.o `pkg-config --libs ujit` -o sample

pkg-config will be used to provide all necessary information about paths to include files, libraries, etc.


LuaVela’s pkg-config file provides facilities for dynamic linking only.

What’s Next

You can extend your sample program using C API for Lua and/or LuaVela’s Extended API Reference.