Forum

> > Off Topic > Lua symbol not found under LuaJIT
Forums overviewOff Topic overviewLog in to reply

English Lua symbol not found under LuaJIT

2 replies
To the start Previous 1 Next To the start

old Lua symbol not found under LuaJIT

Starkkz
Moderator Off Offline

Quote
So I'm trying to play with LuaJIT under LuaJIT (You might think it doesn't make sense but it does), I'm able to load some of the C functions from the lua library but there are other functions that my program cannot find.

This is what I tried.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local ffi = require("ffi")

module("lua")

ffi.cdef [[
  typedef struct lua_State lua_State;
  typedef int (*lua_CFunction) (lua_State * L);
  typedef ptrdiff_t lua_Integer;
  typedef double lua_Number;
  
  lua_State * luaL_newstate (void);
  
  void luaL_openlibs(lua_State * L);
  
  int lua_toboolean(lua_State * L, int index);
  lua_CFunction lua_tocfunction(lua_State * L, int index);
  lua_Integer lua_tointeger(lua_State * L, int index);
  lua_Number lua_tonumber(lua_State * L, int index);
  const void * lua_topointer(lua_State * L, int index);
  const char * lua_tostring(lua_State * L, int index);
  lua_State * lua_tothread(lua_State * L, int index);
  void * lua_touserdata(lua_State * L, int index);
  int lua_type(lua_State * L, int index);
  const char * lua_typename(lua_State * L, int tp);
  int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc);
  void lua_pushboolean(lua_State * L, int b);
  void lua_pushcclosure(lua_State * L, lua_CFunction fn, int n);
  void lua_pushcfunction(lua_State * L, lua_CFunction f);
  void lua_pushinteger(lua_State * L, lua_Integer n);
  void lua_pushlightuserdata(lua_State * L, void * p);
  void lua_pushnil(lua_State * L);
  void lua_pushnumber(lua_State * L, lua_Number n);
  void lua_pushstring(lua_State * L, const char * s);
  int lua_pushthread(lua_State * L);
  void lua_pushvalue(lua_State * L, int index);
  void lua_register(lua_State * L, const char * name, lua_CFunction f);
  
  int luaL_dostring(lua_State * L, const char * str);
  int luaL_dofile(lua_State * L, const char * filename);
  int luaL_loadstring(lua_State * L, const char * s);
  int luaL_loadfile(lua_State * L, const char * filename);
]]

lua = ffi.C

function testFunction(L)
  print("Message: "..lua.luaL_checkstring(L, 1))
end

State = lua.luaL_newstate()
lua.lua_register(State, "testFunction", testFunction)
if lua.luaL_loadstring(State, "testFunction('wasd')") == 0 then
  lua.lua_pcall(State, 1, 0, 0)
end

return ffi.C

I loaded it with this.
1
require("lua")

And it outputs this error.
Quote
lua.lua:51: cannot resolve symbol 'lua_register': No se encontro el proceso especificado.

(Process not found)

Does anyone know why doesn't it load the library completely? I'm having the same problem with luaL_dostring, it doesn't work even if I copy the headers exactly as the Lua 5.1 manual says it.

PS. I tried the code on love2d, and I think it loads LuaJIT from the static library because I'm not using any dynamic library to do this.
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview