Why am I getting an error loading LuaXML that tells me that luaL_regsiter is an undefined symbol?

Viewed 161

I am trying to run a simple Lua script that uses LuaXML. When I run it, it fails with the message:

/usr/bin/lua: error loading module 'LuaXML_lib' from file '/usr/local/lib/lua/5.3/LuaXML_lib.so':
    /usr/local/lib/lua/5.3/LuaXML_lib.so: undefined symbol: luaL_register
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    /usr/local/share/lua/5.3/LuaXML.lua:1: in main chunk
    [C]: in function 'require'
    ./testluaxml.lua:3: in main chunk
    [C]: in ?

Why am I getting this error, and more importantly, how do I fix it?

My test script testluaxml.lua :

#!/usr/bin/lua

require 'LuaXML'

local testXmlFile = xml.load("./mytest.xml")
local node  = testXmlFile:find('tag')
print(node)

The contents of mytext.xml:

<tag>Hello World</tag>

I am running lua 5.3 on Ubuntu (20.04.1).

The answer to a similar question () indicates that this may be due to luarocks compiling the LuaXML module with the lua 5.1 header files. I do not think this is the case here, as this is a brand new lua installation. I installed the packages with this series of commands:

$ sudo apt install lua5.3
$ sudo apt install liblua5.3-dev
$ sudo apt install luarocks
$ sudo luarocks install luaxml
$ sudo luarocks install luafilesystem

When I run ldd on LuaXML_lib.so, I get this output:

$ sudo ldd -v LuaXML_lib.so

linux-vdso.so.1 (0x00007ffcbdba000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6
/lib64/ld-linux/x86-64.s0.2 (0x00007f84afeec000)

Version information for LuaXML_lib.so:
./LuaXML_lib.so:
        libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
/lib/x86_64-linux-gnu/libc.so.6:
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-gnu-64.so.2
        ld-linuxq-x86-64.so.2 (GLIBC_PRIVATE) ==> /lib64/ld-linux-x86-64.so.2
1 Answers

It does look like a Lua version mismatch and given the error, it does look like LuaXML_lib is compiled against Lua 5.1 (as this is where luaL_register was present).

This should be fairly easy to confirm: you can run ldd /usr/local/lib/lua/5.3/LuaXML_lib.so and check the output for the lua library.

Related