How can I add C++11 support to Code::Blocks compiler?

C++11Codeblocks

C++11 Problem Overview


I'm writing some code that requires to have C++11 support for my Code::Blocks 12.11. I am using default GNU GCC Compiler came with MingW. Is there any way I can do this?

C++11 Solutions


Solution 1 - C++11

  1. Go to Toolbar -> Settings -> Compiler
  2. In the Selected compiler drop-down menu, make sure GNU GCC Compiler is selected
  3. Below that, select the compiler settings tab and then the compiler flags tab underneath
  4. In the list below, make sure the box for "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]" is checked
  5. Click OK to save

Solution 2 - C++11

The answer with screenshots (put the checkbox as in the second pic, then press OK):

enter image description here enter image description here

Solution 3 - C++11

A simple way is to write:

-std=c++11

in the Other Options section of the compiler flags. You could do this on a per-project basis (Project -> Build Options), and/or set it as a default option in the Settings -> Compilers part.

Some projects may require -std=gnu++11 which is like C++11 but has some GNU extensions enabled.

If using g++ 4.9, you can use -std=c++14 or -std=gnu++14.

Solution 4 - C++11

Use g++ -std=c++11 -o <output_file_name> <file_to_be_compiled>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmber RoxannaView Question on Stackoverflow
Solution 1 - C++11rovykoView Answer on Stackoverflow
Solution 2 - C++11VityataView Answer on Stackoverflow
Solution 3 - C++11M.MView Answer on Stackoverflow
Solution 4 - C++11Stats_LoverView Answer on Stackoverflow