How to enable C++11 in Eclipse Juno/Kepler/Luna CDT?
There's two things you have to do, first you need to setup your compiler, then you need to setup CDT's language processor. Since you didn't mention which compiler you're using, I'll assume it's GCC but the steps will be similar for other compilers. (Note that you need a compiler that supports C++11, of course.)
Setting up the compiler is fairly straightforward:
- Right click your project and click Properties
- Under C/C++ Build click Settings
- Under GCC C++ Compiler, click Miscellaneous
- In the Other Flags box, append "-std=c++11" to the list of tokens.
- Click Apply and OK
At this point you should be able to rebuild your project and get it to run. But CDT still may show errors for C++11 includes. Here's how you can resolve that:
- Right click your project and click Properties
- Under C/C++ General click "Preprocessor Include Paths, Macros"
- Select the Providers tab
- There should be an item in the list that says something like "GCC Built in Compiler Settings". Select this entry.
- Uncheck the "Use global provider..." option
- Under the list there's an box that says "Command to get compiler specs." Append "-std=c++0x" to this.
- Move the "GCC Built in Compiler Settings" provider at the top of the list using the 'Move Up' button on the right.
- Click Apply and then OK.
- Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes."
C++11 support in Eclipse Kepler Service Release 1 (Build id: 20130919-0819)
In the latest release Eclipse Kepler SR1 you only have to add -std=c++11
- Right click on your project and click Properties
- Navigate to C/C++ General and Preprocessor Include Paths, Macros etc.
- Select the Providers tab
- Add -std=c++11 to Command to get compiler specs:
- Apply changes, the Index should be generated automatically.
The "Command to get compiler specs:"-line should look like:
${COMMAND} -E -P -v -dD "${INPUTS}" -std=c++11
As of CDT 8.3 (available as a Kepler update), there is a new dialect option in build settings:
http://wiki.eclipse.org/CDT/User/NewIn83#Build
I use Eclipse Kepler and to fix it i did this:
1 - Right-Click the Project >> Proprietes >> C/C++ Build :: Settings
2 - Went to GCC G++ Compiler >> Miscellaneous >> Other Flags
i then added -std=c++11
hit apply and ok
That fixed my problem!
I hope it helped!
Running eclipse indigo and cdt 8.0.2 here. I followed all the guides, but it was still necessary to set the preprocessor define by hand to find things like std::unique_ptr. The include file "memory" checks this. Set __cplusplus to 201103L on the "Symbols" tab under "Paths and Symbols" in "C++ General" in project properties.