Windos2010编译lua的方法:
Linux编译lua的方法:
make linux
make install
做完上面的工作之后,就可以用lua 脚本名,举例如下:
[roo@123]# lua my.lua
gcc -I/usr/local/include/ -L/usr/local/lib/ -lm add.c -o add /usr/local/lib/liblua.a -ldl
main.c
#include#include /*如果是Linux编译,就把extern "C"括号去掉*/extern "C"{#include #include #include }int main(){ lua_State *L = luaL_newstate(); luaL_openlibs(L); //const char *buf = "print('Hello World')"; //luaL_dostring(L,buf); luaL_dofile(L,"my.lua"); lua_close(L); getc(stdin); return 0;}
my.lua
print('Hello World');