* About loading C libraries (again)
@ 2020-11-04 10:01 Jairo A. del Rio
2020-11-04 11:44 ` Hans Hagen
0 siblings, 1 reply; 4+ messages in thread
From: Jairo A. del Rio @ 2020-11-04 10:01 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1069 bytes --]
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 :)
[-- Attachment #1.2: Type: text/html, Size: 2065 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About loading C libraries (again)
2020-11-04 10:01 About loading C libraries (again) Jairo A. del Rio
@ 2020-11-04 11:44 ` Hans Hagen
2020-11-05 2:42 ` Jairo A. del Rio
0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2020-11-04 11:44 UTC (permalink / raw)
To: Jairo A. del Rio, mailing list for ConTeXt users
On 11/4/2020 11:01 AM, Jairo A. del Rio wrote:
> 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.
i should add a --permitloadlib option to the context runner then
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About loading C libraries (again)
2020-11-04 11:44 ` Hans Hagen
@ 2020-11-05 2:42 ` Jairo A. del Rio
2020-11-05 9:08 ` Hans Hagen
0 siblings, 1 reply; 4+ messages in thread
From: Jairo A. del Rio @ 2020-11-05 2:42 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 2136 bytes --]
Hi again. I grepped the new release and I see permitloadlib is already
included in mtxrun. Just out of curiosity, is --permitloadlib called via
context or should I use it from mtxrun?
context --permitloadlib file.tex still doesn't have any effect.
Best wishes,
Jairo :)
El mié., 4 de nov. de 2020 a la(s) 06:44, Hans Hagen (j.hagen@xs4all.nl)
escribió:
> On 11/4/2020 11:01 AM, Jairo A. del Rio wrote:
> > 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.
> i should add a --permitloadlib option to the context runner then
>
> Hans
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>
[-- Attachment #1.2: Type: text/html, Size: 2997 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: About loading C libraries (again)
2020-11-05 2:42 ` Jairo A. del Rio
@ 2020-11-05 9:08 ` Hans Hagen
0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2020-11-05 9:08 UTC (permalink / raw)
To: Jairo A. del Rio; +Cc: mailing list for ConTeXt users
On 11/5/2020 3:42 AM, Jairo A. del Rio wrote:
> Hi again. I grepped the new release and I see permitloadlib is already
> included in mtxrun. Just out of curiosity, is --permitloadlib called via
> context or should I use it from mtxrun?
> context --permitloadlib file.tex still doesn't have any effect.
It does here (not that i have a lib to test) so maybe check your path:
.../tex-context/tex/texmf-win64/bin/lib/luametatex/foo/libfoo.dll
(put the file there and run mtxrun --generate)
The lua versions should match and there shopuld be the initialer function.
\enabletrackers[*lib*]
gives some info.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-05 9:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-04 10:01 About loading C libraries (again) Jairo A. del Rio
2020-11-04 11:44 ` Hans Hagen
2020-11-05 2:42 ` Jairo A. del Rio
2020-11-05 9:08 ` Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).