g++ -- missing array header

3.6k views Asked by At

The following simple code can't be compiled by g++ 4.3:

#include <array>

using namespace std;

int main()
{
    std::array<int, 8> myarray;

    return 0;
}

array: No such file or directory

Also, the compiler doesn't seen to understand option '-std=c++11' as is recommended to provide to the compiler. Is there another option?

Thanks.

2

There are 2 answers

0
Carl Norum On

GCC 4.3 and presumably also your C++ library are too old for the support you're looking for. You need a newer version. Here's a link to the GCC C++11 support page, and another link to the libstdc++ C++11 support page.

Alternatively, clang supports all of C++11 with libc++.

0
Gillespie On

For me the problem was that it was a cross compiler that needed to be told where the sysroot was, and supplying --sysroot=<path to sysroot> allowed GCC to find the headers