Reputation: 1484
I have a program written in a combination of c and lua. I know how to compile c programs, and I know how to compile lua programs, but I don't know how I can compile a hybrid program into a single executable. It's also important to note that I'm using the lua c api.
EDIT: just to clarify, I'm not using the lua interpreter in anyway shape or form.
Upvotes: 2
Views: 215
Reputation: 16512
I thing the easiest way would be to store you program a string and then use the luaL_dostring()
function to execute it.
I did not check but I'm pretty sure you can compile the Lua code with luac and store it in a char []
buffer instead of storing the script source code.
This will speed up things a bit by doing the compilation of the source code to Lua VM bytecode once for all at compile time (rather than at runtime).
Something like:
const char *luacode = "print('Hello')";
lua_State *L;
...
...
luaL_dostring (L, luacode);
Upvotes: 3