patterncppCritical
Compiling C++11 with g++
Viewed 0 times
compilingwithstackoverflow
Problem
I'm trying to update my C++ compiler to C++11.
I have searched a bit and I have come to the conclusion that I have to use the flag
Here is the error that I get from the compiler when I attempt to use a library which is included in C++11 (i.e. array):
This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
I have searched a bit and I have come to the conclusion that I have to use the flag
-std=c++0x or -std=gnu++0x, but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu 12.04.)Here is the error that I get from the compiler when I attempt to use a library which is included in C++11 (i.e. array):
#include
#include
int main()
{
std::array arr = {2, 3, 5};
...
}This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
Solution
Flags (or compiler options) are nothing but ordinary command line arguments passed to the compiler executable.
Assuming you are invoking g++ from the command line (terminal):
or
if the above doesn't work.
Assuming you are invoking g++ from the command line (terminal):
$ g++ -std=c++11 your_file.cpp -o your_programor
$ g++ -std=c++0x your_file.cpp -o your_programif the above doesn't work.
Context
Stack Overflow Q#10363646, score: 632
Revisions (0)
No revisions yet.