Embedding LuaVela Using pkg-config¶
Introduction¶
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.
Prerequisites¶
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();
lua_close(L);
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.
Note
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.