<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 16, 2015 at 12:03 PM, Dirk Laurie <span dir="ltr"><<a href="mailto:dirk.laurie@gmail.com" target="_blank">dirk.laurie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">2015-03-16 12:01 GMT+02:00 luigi scarso <<a href="mailto:luigi.scarso@gmail.com">luigi.scarso@gmail.com</a>>:<br>
<br>
> well a C modules compiled is a binary, so it could be reasonable.<br>
<br>
</span>I can see why LuaTeX prefers seaching via kpse. I can't see why<br>
searching on package.path and package.cpath is completely<br>
discarded. They should be retained as the last fallbacks in<br>
package.searchers.<br>
<span class=""><br>
> But in any case<br>
> package.loadlib (libname, funcname)<br>
> should work (libname is something like /<my_path>/core.so).<br>
<br>
</span>That works fine for satisfying external references from C packages.<br>
I.e. if I write a .so that needs liblapack.so, then I should loadlib that.<br>
<br>
But It does not produce Lua-visible objects. It cannot replace<br>
"require".<br>
</blockquote></div><div><br></div><div>This works, </div><div>assuming Linux,  </div><div>a core.so in</div><div>../resources/lib64/</div><div>and funcname luaopen_core</div><div><br></div><div>--</div><div>-- luatex has lfs</div><div>--</div><div><div>local function loadmod(path)</div><div>  local current_dir = lfs.currentdir()</div><div>  local f, err = lfs.chdir(path  .. "/resources/lib64/")</div><div>  if not(f) then </div><div>    print(err)</div><div>    os.exit(1)</div><div>  end</div><div>  local mod_dir = lfs.currentdir()</div><div>  local _core= package.loadlib( mod_dir .."/core.so","luaopen_core")</div><div>  if not(_core) then print("error loading core"); lfs.chdir(current_dir); os.exit(1) end</div><div>  local __core = _core()</div><div>  lfs.chdir(current_dir)<br></div><div>  return  __core</div><div>end</div><div><br></div><div>local path </div><div><br></div><div>path=".."</div><div>local clibm= loadmod(path)</div><div>print(clibm.exp2f(1.23))<br></div></div><div><br></div><div><br></div><div><br></div>-- <br><div class="gmail_signature">luigi<br></div>
</div></div>