c++c++11centos7nghttp2

Why did this error occur? c++ library build


I don't know why this error occurs.

I'm using nghttp2 on centos 7.

My centos supports c++17

Did I forget any options?

Help me please.

Thank you.


    usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support for the \
      ^
    In file included from util.h:52:0,
                     from util.cc:25:
    template.h:44:19: warning: variadic templates only available with -std=c++11 or -std=gnu++11 [enabled by default]
     template <typename... T>
                       ^
    template.h:45:1: error: constexpr’ does not name a type
     constexpr std::array<
     ^
    template.h:45:1: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
    template.h:54:33: error: constexpr’ does not name a type
     template <typename T, size_t N> constexpr size_t array_size(T (&)[N]) {
                                     ^
    template.h:54:33: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
    template.h:58:33: error: constexpr’ does not name a type
     template <typename T, size_t N> constexpr size_t str_size(T (&)[N]) {
                                     ^
    template.h:58:33: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
    template.h:64:31: warning: variadic templates only available with -std=c++11 or -std=gnu++11 [enabled by default]
     template <typename F, typename... T> struct Defer {
                                   ^
    template.h:65:11: error: expected ‘,’ or ‘...’ before ‘&&’ token
       Defer(F &&f, T &&... t)
               ^
    template.h:67:15: error: expected ‘,’ or ‘...’ before ‘&&’ token
       Defer(Defer &&o) noexcept : f(std::move(o.f)) {}
                   ^
    template.h:67:18: error: invalid constructor; you probably meant ‘nghttp2::Defer<F, T> (const nghttp2::Defer<F, T>&)’
       Defer(Defer &&o) noexcept : f(std::move(o.f)) {}
                      ^
    template.h:67:18: error: expected ‘;’ at end of member declaration
    template.h:67:20: error: noexcept’ does not name a type
       Defer(Defer &&o) noexcept : f(std::move(o.f)) {}
                        ^
    template.h:70:9: error: expected nested-name-specifier before ‘ResultType’
       using ResultType = typename std::result_of<typename std::decay<F>::type(
             ^
    template.h:70:9: error: using-declaration for non-member at class scope
    template.h:70:20: error: expected ‘;’ before ‘=’ token
       using ResultType = typename std::result_of<typename std::decay<F>::type(
                        ^
    template.h:70:20: error: expected unqualified-id before ‘=’ token
    template.h:72:3: error: function’ in namespace ‘std’ does not name a type
       std::function<ResultType()> f;
       ^
    template.h: In constructor ‘nghttp2::Defer<F, T>::Defer(F)’:
    template.h:66:9: error: class ‘nghttp2::Defer<F, T>’ does not have any field named ‘f’
           : f(std::bind(std::forward<F>(f), std::forward<T>(t)...)) {}
             ^
    template.h:66:11: error: bind’ is not a member of ‘std’
           : f(std::bind(std::forward<F>(f), std::forward<T>(t)...)) {}
               ^
    template.h:66:11: note: suggested alternative:
    In file included from /usr/include/netinet/in.h:24:0,
                     from /usr/include/netdb.h:27,
                     from util.h:35,
                     from util.cc:25:
    ...


Solution

  • i forgot any options?

    You did and the compiler tells you that exactly:

    error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.


    You are probably using a really old compiler (the one that comes with CentOS by default).

    You need to install Red Hat Developer Toolset which provides up-to-date versions, see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details:

    Developer Toolset is designed for developers working on CentOS or Red Hat Enterprise Linux platform. It provides current versions of the GNU Compiler Collection, GNU Debugger, and other development, debugging, and performance monitoring tools.