Skip to content

Compiling It Successfully on Newer Distributions / g++ Versions #33

@ossie-git

Description

@ossie-git

Compiling lua-requests on any modern distribution will fail with the following error on any modern Linux distribution:

$ luarocks install lua-requests
...
gcc -O2 -fPIC -I/usr/include/lua5.3 -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) {
      |                                                        ^~~~~

Error: Failed installing dependency: https://luarocks.org/xml-1.1.3-1.src.rock - Build error: Failed compiling object src/Parser.o

The problem is due to a C++ feature that was removed in C++17, which is used by newer versions of gcc. To get around this, you can either:

  • install and use an older version of g++
  • pass in flags to tell it to compile using C++14 mode instead

For more on the second option and how to update your .rockspec to do so, refer to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions