lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday 01 August 2006 16:55, Michael Surette wrote:
> I'm just starting to learn lua and thought I'd start with something simple,
> so I downloaded an example file and changed one line to remove an obsolete
> function call.  Here is the result.
>
> #include <stdio.h>
>
> #include "lua.h"
> #include "lualib.h"
> #include "lauxlib.h"
>
> /* the Lua interpreter */
> lua_State* L;
>
> int main ( int argc, char *argv[] )
> {
> 	/* initialize Lua */
> 	L = lua_open();
>
> 	/* load various Lua libraries */
> 	luaopen_base(L);
>         luaopen_table(L);
>         luaopen_io(L);
>         luaopen_string(L);
>         luaopen_math(L);
>
> 	/* cleanup Lua */
> 	lua_close(L);
>
> 	return 0;
> }
>
> I compiles cleanly but gives me an error message when I run it...
>
> PANIC: unprotected error in call to Lua API (no calling environment)
>
> How do I provide a calling environment?
>
> Mike

According to the the 5.1 reference manual, you can't call the luaopen_* 
funtions directly, but have to call them like a lua function.  I'm sure the 
rest will fall in place from there.

Sorry to have bothered you with something so trivial.

Mike