Windos2010编译lua的方法:

http://blog.csdn.net/appletreesujie/article/details/12065369

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 <stdio.h>
#include <string.h>

/*如果是Linux编译,就把extern "C"括号去掉*/ extern "C" { #include <lua.h> #include <lualib.h> #include <lauxlib.h> } 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');

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
猜你喜欢
  • 2021-11-19
  • 2022-12-23
  • 2021-08-11
  • 2022-02-20
  • 2021-07-12
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案