librime-lua icon indicating copy to clipboard operation
librime-lua copied to clipboard

建議: 提供 製作 shared lib 機制

Open shewer opened this issue 3 years ago • 0 comments

我把 src/lib & EXPORT 提取出來 ,使用 luaopen_opencc(lua_State *L,) 註冊 單獨 compile 成 so file 但是 在require 時 總是出現錯誤 error loading module 'modules' from file './modules.so': ./modules.so: undefined symbol: _ZN6opencc6Config11NewFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

namespace OpenccReg {
    ....
}
namespace ModulesReg {
  static lua_Reg funcs[] {
 ..... 
};
  int init(lua_State *L) {
    luaL_newlib(L, funcs);
    return 1;
  }
}
extern "C" {
  int luaopen_modules(lua_State *L) {
    EXPORT(OpenccReg, L); 
    //lua_createtable(L, 0, 0);
    //luaL_setfuncs(L, funcs, 0);
    return ModulesReg::init(L);
  }
}

shewer avatar Sep 27 '22 18:09 shewer