manoelcampos / xml2lua

XML Parser written entirely in Lua that works for Lua 5.1+. Convert XML to and from Lua Tables 🌖💱
MIT License
287 stars 73 forks source link

Doesn't run with the new module system #1

Closed meisterluk closed 7 years ago

meisterluk commented 7 years ago

This library is not compatible with the recent release Lua 5.3.4. First I installed the library via luarocks:

Installing https://luarocks.org/luaxml-101012-1.src.rock
gcc -O2 -fPIC -I/opt/lua-5.3.4/src/ -c LuaXML_lib.c -o LuaXML_lib.o
LuaXML_lib.c: In function ‘Xml_eval’:
LuaXML_lib.c:284:17: warning: implicit declaration of function ‘lua_objlen’ [-Wimplicit-function-declaration]
    int newIndex=lua_objlen(L,-1)+1;
                 ^
LuaXML_lib.c: In function ‘luaopen_LuaXML_lib’:
LuaXML_lib.c:415:2: warning: implicit declaration of function ‘luaL_register’ [-Wimplicit-function-declaration]
  luaL_register(L, "xml", funcs);
  ^
gcc -shared -o LuaXML_lib.so -L/opt/lua-5.3.4/src//lib LuaXML_lib.o
luaxml 101012-1 is now installed in /opt/luarocks-2.4.1/bin (license: MIT/X11)

When trying to run it, the following error is thrown:

ryuu@gaku ~ % lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> luaxml = require("luaxml")
stdin:1: module 'luaxml' not found:
        no field package.preload['luaxml']
        no file '/home/ryuu/.luarocks/share/lua/5.3/luaxml.lua'
        no file '/home/ryuu/.luarocks/share/lua/5.3/luaxml/init.lua'
        no file '/opt/luarocks-2.4.1/bin/share/lua/5.3/luaxml.lua'
        no file '/opt/luarocks-2.4.1/bin/share/lua/5.3/luaxml/init.lua'
        no file '/opt/luarocks-2.4.1/bin/lib/luarocks/rocks/luaxml.lua'
        no file './luaxml.lua'
        no file '/home/ryuu/.luarocks/lib/lua/5.3/luaxml.so'
        no file '/opt/luarocks-2.4.1/bin/lib/lua/5.3/luaxml.so'
        no file '/usr/local/lib/lua/5.3/luaxml.so'
        no file '/usr/local/lib/lua/5.3/loadall.so'
        no file './luaxml.so'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?
>

This is apparently because of the changes in the module system between Lua versions 5.0 and 5.2. lauxlib.h does not define luaL_register per default anymore:

/* compatibility with old module system */
#if defined(LUA_COMPAT_MODULE)

LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
                                   int sizehint);
LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
                                const luaL_Reg *l, int nup);

#define luaL_register(L,n,l)    (luaL_openlib(L,(n),(l),0))

#endif

I would love to see this package working with Lua 5.3.4

manoelcampos commented 7 years ago

Hello @meisterluk, This is not the LuaXML module you are talking about. My module is an XML parser written entirely in Lua and the one you mentioned is an homonymous module that relies on some C code. My module is just an updated Lua 5 version of a former implementation. The module you are looking for is available at https://github.com/LuaDist/luaxml

meisterluk commented 7 years ago

I should have seen this. Thanks a lot and sorry for the noise 😞

manoelcampos commented 7 years ago

No problem.