[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: luasocket in C
- From: Leo Leo <leo4mailing@...>
- Date: Thu, 5 Jan 2006 23:17:39 +0100
Hi,
i'm a newbie in Lua and i try to execute from a C program a lua code using luasocket.
----------------- lua_test.c --------------------------------
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
void run(char *filename);
int main(int argc, char *argv[])
{
lua_State *L = lua_open();
luaopen_base(L);
luaopen_io(L);
luaopen_string(L);
luaopen_math(L);
if (luaL_loadfile(L, "/usr/share/lua50/compat-5.1.lua")) {
error(L, "Cannot load compat 5.1 file: %s",
lua_tostring(L, -1));
}
if (luaL_loadfile(L, argv[1])) {
error(L, "Cannot load file: %s",
lua_tostring(L, -1));
}
if (lua_pcall(L, 0, 0, 0)) {
error(L, "Cannot run file: %s",
lua_tostring(L, -1));
}
lua_close(L);
}
------------------- socket.lua ---------------------------------------
local socket = require("socket")
---------------------------------------------------------
$ lua socket.lua
lua: /usr/share/lua50/socket.lua:11: could not load package `string' from path `/home/leo/.lua50/?.lua;/home/leo/.lua50/?;/home/leo/share/lua50/?.lua;/home/leo/share/lua50/?;/usr/share/lua50/?.lua;/usr/share/lua50/?;/usr/local/share/lua50/?.lua;/usr/local/share/lua50/?;?.lua;?'
stack traceback:
[C]: in function `require'
/usr/share/lua50/socket.lua:11: in main chunk
[C]: in function `require'
socket.lua:1: in main chunk
[C]: ?
$ export LUA_PATH="/usr/share/lua50/?.lua;?.lua"
$ export LUA_CPATH="/usr/lib/?.so;?.so"
$ export LUA_INIT=@/usr/share/lua50/compat-5.1.lua
$ lua socket.lua
$ ./lua_test socket.lua
./lua_test: /usr/share/lua50/socket.lua:11: could not load package `string' from path `/usr/share/lua50/?.lua;?.lua': Unknown error 134514977
It seems that env is not used when I call the lua script from my C program. Can you give me some hints about that ? Why it needs string,
the libs are already added in the C programm ?
Reguards
Leo