bkacjios / Lumble

A mostly pure Lua based mumble implementation for creating a bot
11 stars 2 forks source link

ocb.so error "undefined symbol: luaL_setmetatable". Can't use provided ocb.so, can't build it #4

Closed CaptainZidgel closed 4 years ago

CaptainZidgel commented 4 years ago

Attempted to run with the provided ocb.so

$ luajit client.lua 
luajit: error loading module 'ocb.aes128' from file './ocb.so':
    ./ocb.so: undefined symbol: luaL_setmetatable
stack traceback:
    [C]: at 0x55bb07d339d0
    [C]: in function 'require'
    ./modules/lumble/client/init.lua:27: in main chunk
    [C]: in function 'require'
    ./modules/lumble/init.lua:1: in main chunk
    [C]: in function 'require'
    ./modules/concommand.lua:6: in main chunk
    [C]: in function 'require'
    client.lua:13: in main chunk
    [C]: at 0x55bb07cea440

Downloaded the required headers and attempted to use build.sh in Lumble/ocb-aes128 in case the compiled ocb was outdated compared to the code.

$ ./build.sh
main.cpp: In function ‘int ocb_aes128_new(lua_State*)’:
main.cpp:13:2: error: ‘luaL_setmetatable’ was not declared in this scope
  luaL_setmetatable(L, LUA_OCB_AES128);
  ^~~~~~~~~~~~~~~~~
main.cpp:13:2: note: suggested alternative: ‘lua_setmetatable’
  luaL_setmetatable(L, LUA_OCB_AES128);
  ^~~~~~~~~~~~~~~~~
  lua_setmetatable
g++: error: ocb.o: No such file or directory

I don't know anything about C, the C API or what ocb is supposed to even do, but I attempted to resolve the issue by following the suggestion but it only created new errors.

bkacjios commented 4 years ago

ocb is a module for encrypting UDP packets before sending them to the server. Technically it isn't needed, and can be stripped from the code rather easily since it will fall back to using TCP packets instead.

luaL_setmetatable is defined here in luajit: https://github.com/LuaJIT/LuaJIT/blob/f0e865dd4861520258299d0f2a56491bd9d602e1/src/lauxlib.h#L92

So I'm not entirely sure why this isn't defined for you. Are you using LuaJit-beta2.1?

Anyway, this definition should get it to compile for you.

#define luaL_setmetatable(L, tname) lua_getfield(L, LUA_REGISTRYINDEX, tname); lua_setmetatable(L, -2);
CaptainZidgel commented 4 years ago

Ah, that would do it then. I'm still using Luajit 2.0.5. I didn't even know beta2.1 existed, which is kind of sad because it's right on Luajit's front page and I visit that every time I have to reinstall on a machine. The define statement worked quite well, thank you. ocb.so compiled and I can now start the bot. If I run into any more problems anywhere else I'll update to the latest Luajit beta.