1

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.

Mark
  • 6,052
  • 8
  • 61
  • 129
  • 2
    I believe `std::array` was first added as part of TR1. If upgrading compilers is not an option, try changing the include to `#include ` and then use it as `std::tr1::array` – Praetorian Aug 30 '13 at 19:15
  • Praetorian, thanks it helped. – Mark Aug 31 '13 at 11:51
  • Can this comment be made an "answer". It works for people using older compilers! – Anu Jan 27 '15 at 14:29

2 Answers2

2

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++.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
0

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

Gillespie
  • 5,780
  • 3
  • 32
  • 54