GCC and G++ versions are independent of Codeblocks, which is only the IDE. To have updated versions of the compilers you need to install them by downloading the original websites. In windows the mingw allows you to install a configurator (mingw-get) to install the various compilers and libraries on your machine. In most linux distributions gcc
is already installed, but can also install the latest version with a simple command on the terminal.
Some of the build settings you mention already exist in the Codeblocks configuration frames themselves, such as the -std=
for the version.
Go to Settings > Compiler:
In the Compiler Settings tab and Compiler Flags sub tab choose Have g++ follow the C++11 ISO C++ language standard [-std=c++11]
:
In the same list a little further down there are also performance options, which include the -O2
who mentioned:
As apart from flag -O3
gives you even more optimization for speed.
Any flags that do not exist as an option in Codeblocks can be added via the sub separator Other Compiler options:
However, Codeblocks already links by default to the library math
, making the flag -lm
redundant, but may vary based on the installation/configuration you made.
Build example with settings shown in this answer: