[luatex] question about loading an external lua library into Lua(La)TeX

Mico Loretan mico.loretan at mac.com
Tue Feb 25 21:45:32 CET 2014


Dear all,

The "lbn" library by Luiz Henrique de Figueiredo is described as a "fast integer-only arbitrary precision library"; see http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbn for a link to the source. I downloaded the tar.gz file and managed to compile the package's code into a lua library file called "bn.so", using either Lua 5.2.3 or LuaTeX 0.76 as the "Lua executable". Running the little test program that comes with the package, either via "lua test.lua" or via "luatex test.lua", also works without a hitch.

I would like to be able to use this library in a Lua(La)TeX document. Consider the following MWE:

    % !TEX TS-program = lualatex
    \documentclass{article}
    \usepackage{luacode} % for 'luacode' environment
    \begin{luacode}
    require "bn" -- load 'bn' library
    \end{luacode}
    \begin{document}
    Hello World.
    \end{document}

Unfortunately, things aren't going smoothly. Here are some excerpts from the log file:


    This is LuaTeX, Version beta-0.76.0-2013061817 (rev 4627)  (format=lualatex 2014.2.8)  25 FEB 2014 21:31
    ...
    (/usr/local/texlive/2013/texmf-dist/tex/lualatex/luacode/luacode.sty
    Package: luacode 2012/01/23 v1.2a lua-in-tex helpers (mpg)
    ...
     (/usr/local/texlive/2013/texmf-dist/tex/luatex/luatexbase/mcb.lua)
    Lua module: luatexbase-mcb 2013/05/11 0.6 register several functions in a callback
    ))
    \luacode at lines=\toks14
    \luacode at table@soft=\luatexcatcodetable13
    )
    ! LuaTeX error error loading module 'bn' from file './bn.so':
    	dlopen(./bn.so, 6): Symbol not found: _luaL_checklstring
      Referenced from: /Users/mico/Documents/tex/bn.so
      Expected in: flat namespace
     in /Users/mico/Documents/tex/bn.so
    stack traceback:
    	[C]: in ?
    	[C]: in ?
    	[C]: in function 'require'
    	[string "\directlua "]:1: in main chunk.
    \luacode at dbg@exec ...code at maybe@printdbg {#1} #1 }
                                                      
    l.6 \end{luacode}



Again, let me stress that the library "bn" seems to work fine when accessed from the package's test file, viz., test.lua. It's only when the library is being accessed from inside the "luacode" environment that things go off track. Is there some way to fix this?

Thanks, Mico






More information about the luatex mailing list