[NTG-context] About loading C libraries (again)

Jairo A. del Rio jairoadelrio6 at gmail.com
Wed Nov 4 11:01:29 CET 2020


Hi. I've just read in the LuaMetaTeX manual that --permitloadlib allows
loading compiled (.so/.dll) libraries. However, when I try it using ConTeXt
I have an error message (example below):

%hello.tex

\starttext

\startluacode

local hello = require"hellolib" -- hellolib.so

context(hello.helloworld())

\stopluacode

\stoptext

%hello.c
#include <lua.h>
#include <lauxlib.h>

static int helloworld (lua_State *L) {
    char hello[] = "Hello world!";
    lua_pushstring(L, hello);
    return 1;
}

static const struct luaL_Reg hellolib [] = {
      {"helloworld", helloworld},
      {NULL, NULL}
    };

int luaopen_hellolib (lua_State *L){
    luaL_newlib(L, hellolib);
    return 1;
}

error (lua loadlib): you can only load external libraries when
--permitloadlib is given


On the other hand, manually calling LuaMetaTeX with the ConTeXt format and
--permitloadlib gives the expected result (in this case, a "Hello world!").

How is the correct way to load those libraries? Thank you very much and
sorry if my question seems to be weird.

Best regards,

Jairo :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20201104/03e9f337/attachment.htm>


More information about the ntg-context mailing list