I am a self-taught C++ programmer and have been using the DevC++ IDE to run my programs thus far. But I am disappointed that, for some unknown reason, the current DevC++ IDE I have does NOT have a means to enable the C++11 option!! That is why I'm trying out an alternative - the Code::Blocks IDE, which I downloaded from the Sourceforge.net website.
I successfully ran the ubiquitous 'Hello World' program. However, the crucial option "Have g++ follow the C++11 ISO C++ language standard [-std=C++11]" is curiously missing under Settings->Compiler!! My worst fears were confirmed when I tried to include the <random> and <chrono> header files, to no avail.
Please how can I locate/get this very much needed C++11 option and have it enabled?
Really? Did you check this on the Sourceforge.net website?
The Code::Blocks version I downloaded from there is codeblocks-16.01mingw-setup.exe. The reason I got this one is because I read on the www.learncpp.com website that Windows users should download the version with MinGW bundled.
By the way, there is another version on there that is just codeblocks-16.01-setup.exe. Not sure if this is the one I should download!
Edit: I installed using codeblocks-16.01-setup.exe which automatically detected TDM-GCC as a GNU GCC Compiler. After running Code::Blocks and checking the settings window, I see https://s16.postimg.org/ph5mmb1ed/Capture.png
You might find that you like TDM-GCC more than regular MinGW. I highly recommend you give it a try. http://tdm-gcc.tdragon.net/ After all, it is a descendant of MinGW-64
Yes they are compilers. TDM-GCC is derived from MinGW-64; the differences are described on TDM-GCC's website. A few too many differences for me just to repeat here.
Firstly, for my set up I downloaded and installed MinGW from MinGW.org, installing it to C:/MinGW (the default setting). Then in Code::Blocks I clicked Settings -> Compiler...
First thing I did was copy the GNU GCC Compiler and named the copy to MinGW GCC Compiler. Then in the Toolchain executables tab I directed the Compiler's installation directory to C:/MinGW and directed it to proper program files.
MinGW doesn't recognize the -std=c++11 flag so go into Compiler settings tab and uncheck the box in the Compiler Flags tab. Go into the Other options tab beside Compiler Flags and enter -std=gnu++11
After all this be sure to set it as your default compiler in Code::Blocks.
I would recommend against gnu++11, just stick with c++11 by using TDM-GCC that way the code you write complies with C++ standards. GNU extensions can cause code that works on the GNU compiler to suddenly not work if you switch to a fancier compiler someday such as Intel, MSVC, or other proprietary compilers.
Turns out my issue was a problem with stdlib.h and wchar.h which will be fixed in the next release. Was given the fixed headers to fix it for now. Sadly I don't know why he is having a problem with the headers he mentioned.
A relieving, albeit confusing, update on the issue of this thread! What I have observed is that in my Start menu, there are two CodeBlocks instances: CodeBlocks and CodeBlocks(Launcher). Starting the CodeBlocks IDE using the former results in the problem I introduced in this thread while using the latter has that desired key C++11 option under the Settings->Compiler Settings->Compiler Flags path.
- Why do I have these two instances?
- Is there anything I could have done wrong during the installation?
Is it possible you already had an older version of CodeBlocks installed, so that one instance is the older one (without the C++11 support) and the other is the newer?
(I've never used CodeBlocks, so this is a totally random guess.)