Lua 标准库(standard libraries)
一、Lua十标准大库:
basic library、coroutine library、package library、string manipulation、basic UTF-8 support、table manipulation、mathematical functions、input and output、operating system facilities、debug facilities.
To have acces to these libraries, the C host program should call the luaL_openlibs functions, which opens all standard libraries. Alternatively, the host program can open them individually by using luaL_requiref to call luaopen_base、luaopen_coroutine、luaopen_package、luaopen_string、luaopen_utf8、luaopen_table、luaopen_math、luaopen_io、luaopen_os、luaopen_debug. These functions are declared in lualib.h.
例子:
1)创建lua虚拟机
lua_State *lua_state = luaL_newstate();
2)加载Lua库
a、luaL_openlibs(lua_state);
b、luaL_requiref(lua_state, "base", luaopen_base, 1);
lua_pop(lua_state,1);