Eclipse / g ++ doesn't recognize flag "-std = c ++ 11"

I am running CentOS 6.6 x64 with Eclipse Luna and g ++ 4.7.2 ( devtoolset-2 provided ). I am using Eclipse's built in automatic Makefile generation.

I enabled g ++ 4.7.2 using scl enable devtoolset-2 bash

[me @dev ~] # g ++ - version of g ++ (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see source for copy conditions. There is no guarantee here; even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Unfortunately, when compiling, Eclipse throws errors saying "-std = C ++ 11" is not a valid option. I have set the dialect in project properties -> C / C ++ Build -> Settings -> Dialect -> "Other dialects" with the value "-std = C ++ 11".

Call: GCC C ++ Compiler: *** Waiting for unfinished jobs .... g ++ -std = C ++ 11 .... cc1plus: Error: Unrecognized command line option "-std = C ++ 11"

I tried using the "Language Standard" option with "-std = C ++ 0x" but it generates errors on compilation

map<int, MyObject*> myObjectMap; 
// assume I've added in objects before the loop
for (const auto& kv : myObjectMap) // line 249
{
    // do things
}

      

249: error: expected initializer before ': token

+3


source to share


1 answer


If you want Eclipse to work with it installed devtoolset-2

, you need to start Eclipse from an enabled environment devtoolset

. Most obviously it can be done from the terminal with

scl enable devtoolset-2 eclipse &

      



Explanation: devtoolset

Installed as an alternate development environment that is inactive by default. Only with explicit activation will you receive a new version of the compiler that also understands the -std=c++11

functions you were looking for.

+3


source







All Articles