On Mon, Mar 16, 2015 at 12:03 PM, Dirk Laurie <[email protected]> wrote:
> 2015-03-16 12:01 GMT+02:00 luigi scarso <[email protected]>: > > > well a C modules compiled is a binary, so it could be reasonable. > > I can see why LuaTeX prefers seaching via kpse. I can't see why > searching on package.path and package.cpath is completely > discarded. They should be retained as the last fallbacks in > package.searchers. > > > But in any case > > package.loadlib (libname, funcname) > > should work (libname is something like /<my_path>/core.so). > > That works fine for satisfying external references from C packages. > I.e. if I write a .so that needs liblapack.so, then I should loadlib that. > > But It does not produce Lua-visible objects. It cannot replace > "require". > This works, assuming Linux, a core.so in ../resources/lib64/ and funcname luaopen_core -- -- luatex has lfs -- local function loadmod(path) local current_dir = lfs.currentdir() local f, err = lfs.chdir(path .. "/resources/lib64/") if not(f) then print(err) os.exit(1) end local mod_dir = lfs.currentdir() local _core= package.loadlib( mod_dir .."/core.so","luaopen_core") if not(_core) then print("error loading core"); lfs.chdir(current_dir); os.exit(1) end local __core = _core() lfs.chdir(current_dir) return __core end local path path=".." local clibm= loadmod(path) print(clibm.exp2f(1.23)) -- luigi
