I've compiled Lua 5.2 on Debian x86-64 with make posix, and am trying to compile the following with the command gcc -ldl -llua main.c
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
int main() {
lua_State *L = luaL_newstate();
luaL_openlibs(L);
dofile("test.lua");
return 0;
}
and get unresolved references to the lua functions
Assuming your error is
undefined reference to `dofile'
then your problem is that dofile is a lua function and not a C one.
You probably want luaL_dofile(L, "test.lua").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With