Which libraries are available via ffi for texlive luatex with no other installation?












3















Recent versions of luatex (≥ 1.0.3) come with ffi. That means that one can call a C library from lua inside a TeX file. Some (very) recent examples on TeX.sx have proven its power.



Assuming current TeXlive (2018) or next release (TeXlive 2019), what libraries can be accessed with no additional installation from the user (from a package writer point of vue)?










share|improve this question


















  • 1





    I have written a couple of more answers on LuaTeX FFI than you linked: tex.stackexchange.com/search?q=user%3A10995+LuaTeX+FFI

    – Henri Menke
    Feb 17 at 23:21











  • On GitHub I have some Gists using FFI: Call other scripting languages from LuaJIT via FFI and Render an SVG image as PDF using librsvg2 and cairo

    – Henri Menke
    Feb 17 at 23:23


















3















Recent versions of luatex (≥ 1.0.3) come with ffi. That means that one can call a C library from lua inside a TeX file. Some (very) recent examples on TeX.sx have proven its power.



Assuming current TeXlive (2018) or next release (TeXlive 2019), what libraries can be accessed with no additional installation from the user (from a package writer point of vue)?










share|improve this question


















  • 1





    I have written a couple of more answers on LuaTeX FFI than you linked: tex.stackexchange.com/search?q=user%3A10995+LuaTeX+FFI

    – Henri Menke
    Feb 17 at 23:21











  • On GitHub I have some Gists using FFI: Call other scripting languages from LuaJIT via FFI and Render an SVG image as PDF using librsvg2 and cairo

    – Henri Menke
    Feb 17 at 23:23
















3












3








3








Recent versions of luatex (≥ 1.0.3) come with ffi. That means that one can call a C library from lua inside a TeX file. Some (very) recent examples on TeX.sx have proven its power.



Assuming current TeXlive (2018) or next release (TeXlive 2019), what libraries can be accessed with no additional installation from the user (from a package writer point of vue)?










share|improve this question














Recent versions of luatex (≥ 1.0.3) come with ffi. That means that one can call a C library from lua inside a TeX file. Some (very) recent examples on TeX.sx have proven its power.



Assuming current TeXlive (2018) or next release (TeXlive 2019), what libraries can be accessed with no additional installation from the user (from a package writer point of vue)?







luatex texlive ffi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 17 at 20:48









cjorssencjorssen

5,626225104




5,626225104








  • 1





    I have written a couple of more answers on LuaTeX FFI than you linked: tex.stackexchange.com/search?q=user%3A10995+LuaTeX+FFI

    – Henri Menke
    Feb 17 at 23:21











  • On GitHub I have some Gists using FFI: Call other scripting languages from LuaJIT via FFI and Render an SVG image as PDF using librsvg2 and cairo

    – Henri Menke
    Feb 17 at 23:23
















  • 1





    I have written a couple of more answers on LuaTeX FFI than you linked: tex.stackexchange.com/search?q=user%3A10995+LuaTeX+FFI

    – Henri Menke
    Feb 17 at 23:21











  • On GitHub I have some Gists using FFI: Call other scripting languages from LuaJIT via FFI and Render an SVG image as PDF using librsvg2 and cairo

    – Henri Menke
    Feb 17 at 23:23










1




1





I have written a couple of more answers on LuaTeX FFI than you linked: tex.stackexchange.com/search?q=user%3A10995+LuaTeX+FFI

– Henri Menke
Feb 17 at 23:21





I have written a couple of more answers on LuaTeX FFI than you linked: tex.stackexchange.com/search?q=user%3A10995+LuaTeX+FFI

– Henri Menke
Feb 17 at 23:21













On GitHub I have some Gists using FFI: Call other scripting languages from LuaJIT via FFI and Render an SVG image as PDF using librsvg2 and cairo

– Henri Menke
Feb 17 at 23:23







On GitHub I have some Gists using FFI: Call other scripting languages from LuaJIT via FFI and Render an SVG image as PDF using librsvg2 and cairo

– Henri Menke
Feb 17 at 23:23












1 Answer
1






active

oldest

votes


















3














Without additional installation only the symbols from LuaTeX itself and its dynamically linked libraries are accessible. However, the interesting question is which symbols are accessible which I will show in the following.



Finding symbols



The tools nm and ldd I use below should be available on any POSIX system. On Windows you'd use dumpbin.exe tool for these jobs.



You can find a list of symbols using the nm tool. The grep ' T ' filters only symbols in the text section of the executable (i.e. only functions are shown). Because in TeX Live 2018 there is some C++ code linked into LuaTeX you have to use the --demangle option to get something human readable.



$ nm -D --demangle `which luatex` | grep ' T '
[...huge list...]


I'm not sure how useful this is. I have never called a function from the LuaTeX executable.



To find the dynamically linked libraries you can use the ldd tool.



$ ldd `which luatex`
linux-vdso.so.1 (0x00007ffe4d118000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faa4ba0d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa4b66f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa4b27e000)
/lib64/ld-linux-x86-64.so.2 (0x00007faa4bc11000)


The symbols defined by these libraries can be looked up using the nm tool again but it's better to look in the corresponding documentation. The libraries most useful to you are probably libm.so.6 which is the C mathematical functions library (reference) and libc.so.6 which is the C standard library (reference). On POSIX systems this includes the full POSIX C library (reference).



When using the FFI all these symbols are available through the ffi.C handle without loading a library using ffi.load.



Cross-platform FFI code



If you restrict the set of functions you call via FFI to the C standard library the resulting code should be portable between POSIX systems and Windows.






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475388%2fwhich-libraries-are-available-via-ffi-for-texlive-luatex-with-no-other-installat%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Without additional installation only the symbols from LuaTeX itself and its dynamically linked libraries are accessible. However, the interesting question is which symbols are accessible which I will show in the following.



    Finding symbols



    The tools nm and ldd I use below should be available on any POSIX system. On Windows you'd use dumpbin.exe tool for these jobs.



    You can find a list of symbols using the nm tool. The grep ' T ' filters only symbols in the text section of the executable (i.e. only functions are shown). Because in TeX Live 2018 there is some C++ code linked into LuaTeX you have to use the --demangle option to get something human readable.



    $ nm -D --demangle `which luatex` | grep ' T '
    [...huge list...]


    I'm not sure how useful this is. I have never called a function from the LuaTeX executable.



    To find the dynamically linked libraries you can use the ldd tool.



    $ ldd `which luatex`
    linux-vdso.so.1 (0x00007ffe4d118000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faa4ba0d000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa4b66f000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa4b27e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007faa4bc11000)


    The symbols defined by these libraries can be looked up using the nm tool again but it's better to look in the corresponding documentation. The libraries most useful to you are probably libm.so.6 which is the C mathematical functions library (reference) and libc.so.6 which is the C standard library (reference). On POSIX systems this includes the full POSIX C library (reference).



    When using the FFI all these symbols are available through the ffi.C handle without loading a library using ffi.load.



    Cross-platform FFI code



    If you restrict the set of functions you call via FFI to the C standard library the resulting code should be portable between POSIX systems and Windows.






    share|improve this answer






























      3














      Without additional installation only the symbols from LuaTeX itself and its dynamically linked libraries are accessible. However, the interesting question is which symbols are accessible which I will show in the following.



      Finding symbols



      The tools nm and ldd I use below should be available on any POSIX system. On Windows you'd use dumpbin.exe tool for these jobs.



      You can find a list of symbols using the nm tool. The grep ' T ' filters only symbols in the text section of the executable (i.e. only functions are shown). Because in TeX Live 2018 there is some C++ code linked into LuaTeX you have to use the --demangle option to get something human readable.



      $ nm -D --demangle `which luatex` | grep ' T '
      [...huge list...]


      I'm not sure how useful this is. I have never called a function from the LuaTeX executable.



      To find the dynamically linked libraries you can use the ldd tool.



      $ ldd `which luatex`
      linux-vdso.so.1 (0x00007ffe4d118000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faa4ba0d000)
      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa4b66f000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa4b27e000)
      /lib64/ld-linux-x86-64.so.2 (0x00007faa4bc11000)


      The symbols defined by these libraries can be looked up using the nm tool again but it's better to look in the corresponding documentation. The libraries most useful to you are probably libm.so.6 which is the C mathematical functions library (reference) and libc.so.6 which is the C standard library (reference). On POSIX systems this includes the full POSIX C library (reference).



      When using the FFI all these symbols are available through the ffi.C handle without loading a library using ffi.load.



      Cross-platform FFI code



      If you restrict the set of functions you call via FFI to the C standard library the resulting code should be portable between POSIX systems and Windows.






      share|improve this answer




























        3












        3








        3







        Without additional installation only the symbols from LuaTeX itself and its dynamically linked libraries are accessible. However, the interesting question is which symbols are accessible which I will show in the following.



        Finding symbols



        The tools nm and ldd I use below should be available on any POSIX system. On Windows you'd use dumpbin.exe tool for these jobs.



        You can find a list of symbols using the nm tool. The grep ' T ' filters only symbols in the text section of the executable (i.e. only functions are shown). Because in TeX Live 2018 there is some C++ code linked into LuaTeX you have to use the --demangle option to get something human readable.



        $ nm -D --demangle `which luatex` | grep ' T '
        [...huge list...]


        I'm not sure how useful this is. I have never called a function from the LuaTeX executable.



        To find the dynamically linked libraries you can use the ldd tool.



        $ ldd `which luatex`
        linux-vdso.so.1 (0x00007ffe4d118000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faa4ba0d000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa4b66f000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa4b27e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007faa4bc11000)


        The symbols defined by these libraries can be looked up using the nm tool again but it's better to look in the corresponding documentation. The libraries most useful to you are probably libm.so.6 which is the C mathematical functions library (reference) and libc.so.6 which is the C standard library (reference). On POSIX systems this includes the full POSIX C library (reference).



        When using the FFI all these symbols are available through the ffi.C handle without loading a library using ffi.load.



        Cross-platform FFI code



        If you restrict the set of functions you call via FFI to the C standard library the resulting code should be portable between POSIX systems and Windows.






        share|improve this answer















        Without additional installation only the symbols from LuaTeX itself and its dynamically linked libraries are accessible. However, the interesting question is which symbols are accessible which I will show in the following.



        Finding symbols



        The tools nm and ldd I use below should be available on any POSIX system. On Windows you'd use dumpbin.exe tool for these jobs.



        You can find a list of symbols using the nm tool. The grep ' T ' filters only symbols in the text section of the executable (i.e. only functions are shown). Because in TeX Live 2018 there is some C++ code linked into LuaTeX you have to use the --demangle option to get something human readable.



        $ nm -D --demangle `which luatex` | grep ' T '
        [...huge list...]


        I'm not sure how useful this is. I have never called a function from the LuaTeX executable.



        To find the dynamically linked libraries you can use the ldd tool.



        $ ldd `which luatex`
        linux-vdso.so.1 (0x00007ffe4d118000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007faa4ba0d000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa4b66f000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa4b27e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007faa4bc11000)


        The symbols defined by these libraries can be looked up using the nm tool again but it's better to look in the corresponding documentation. The libraries most useful to you are probably libm.so.6 which is the C mathematical functions library (reference) and libc.so.6 which is the C standard library (reference). On POSIX systems this includes the full POSIX C library (reference).



        When using the FFI all these symbols are available through the ffi.C handle without loading a library using ffi.load.



        Cross-platform FFI code



        If you restrict the set of functions you call via FFI to the C standard library the resulting code should be portable between POSIX systems and Windows.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 17 at 23:33

























        answered Feb 17 at 23:15









        Henri MenkeHenri Menke

        75.4k8164276




        75.4k8164276






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475388%2fwhich-libraries-are-available-via-ffi-for-texlive-luatex-with-no-other-installat%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?