Can't install lua xml trough luarocks

177 Views Asked by At

I'm trying to install lua-requests with luarocks, it requires xml, that fails to install.

Log says that C++17 can't work with xml, I tried to change it somehow, but I don't know how and where I should do it...

xml 1.1.3-1 depends on lua >= 5.1, < 5.4 (5.1-1 provided by VM)
xml 1.1.3-1 depends on lub >= 1.0.3, < 2 (1.0.7-1 installed)
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/Parser.cpp -o src/Parser.o -Iinclude -Isrc/bind -Isrc/vendor
In file included from include/xml/Parser.h:33,
                 from src/Parser.cpp:1:
src/bind/dub/dub.h:298:48: error: ISO C++17 does not allow dynamic exception specifications
  298 | lua_Number checknumber(lua_State *L, int narg) throw(dub::TypeException);
      |                                                ^~~~~
src/bind/dub/dub.h:299:50: error: ISO C++17 does not allow dynamic exception specifications
  299 | lua_Integer checkinteger(lua_State *L, int narg) throw(dub::TypeException);
      |                                                  ^~~~~
src/bind/dub/dub.h:300:63: error: ISO C++17 does not allow dynamic exception specifications
  300 | const char *checklstring(lua_State *L, int narg, size_t *len) throw(dub::TypeException);
      |                                                               ^~~~~
src/bind/dub/dub.h:301:82: error: ISO C++17 does not allow dynamic exception specifications
  301 | void **checkudata(lua_State *L, int ud, const char *tname, bool keep_mt = false) throw(dub::Exception);
      |                                                                                  ^~~~~
src/bind/dub/dub.h:304:82: error: ISO C++17 does not allow dynamic exception specifications
  304 | void **checksdata(lua_State *L, int ud, const char *tname, bool keep_mt = false) throw(dub::Exception);
      |                                                                                  ^~~~~
src/bind/dub/dub.h:307:62: error: ISO C++17 does not allow dynamic exception specifications
  307 | void **checksdata_d(lua_State *L, int ud, const char *tname) throw(dub::Exception);
      |                                                              ^~~~~
src/bind/dub/dub.h:317:56: error: ISO C++17 does not allow dynamic exception specifications
  317 | inline const char *checkstring(lua_State *L, int narg) throw(dub::TypeException) {
      |                                                        ^~~~~
2

There are 2 best solutions below

0
Levy Gu On

You should modify the error part(remove the throw) code, and use luarocks to make it.

example for modified error part.

lua_Number checknumber(lua_State *L, int narg) throw(dub::TypeException);

should be modified like this.

lua_Number checknumber(lua_State *L, int narg);

Here is my solution on Amazon Linux 2023.

cd ~
luarocks unpack xml
cd ~/xml-1.1.3-1/xml
# modify error file(src/bind/dub/dub.h, src/bind/dub/dub.cpp),
# remove the throw part.
luarocks make xml-1.1.3-1.rockspec

and xml will be installed

0
Aiq0 On

Same problem is reported in lua-requests bug reporter. There is an open pull request to fix this issue in xml library, but it was last updated 8 years ago and it looks like it is no longer maintained and original author is no longer active.

You can either modify source code as specified in pull request, or update .luarocks file as mentioned here. Basically you just need to compile it with C++14 standard.