Change compiler settings in CodeBlocks

I am going to participate in a programming Olympiad and I need to configure the compiler, in the case of CodeBlocks, in the following ways:

C: GCC compiler version 8.2 or higher-command line: gcc-lm-O2-static-the executable source.c

C++: G++ compiler version 8.2 or higher-command line: G++ -std=C++11-lm-O2-static-the executable source.cpp

How do I do this setting? And how can I adapt the debugger for this version of compiler?

Author: Rahilly, 2019-04-29

2 answers

The 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 sites. On windows 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 you can also install the latest version with a simple command on the terminal.

Some of the build settings you mention already exist in CodeBlocks ' own configuration frames, such as the -std= for the release.

Go to Settings > Compiler:

insert the description of the image here

In the Compiler settings tab and Compiler Flags sub tab choose Have g++ follow the C++11 ISO C++ language standard [-std=c++11]:

insert the description of the image here

In the same list a little further down has also performance options, which include the -O2 which mentioned:

insert the description of the image here

As separate to flag -O3 it gives you even more optimization for speed.

Any flags that do not exist as an option in CodeBlocks can be appended via the other compiler options sub-tab:

insert the description of the image here

However, CodeBlocks already Links by default with the math library, making the flag -lm redundant, but may vary based on installation / configuration you did.

Build example with the settings shown in this answer:

insert the description of the image here

 1
Author: Isac, 2019-04-29 13:35:21

Hello, using CodeBlock you must enter

Menubar Settings - >Compiler and Debugger Select GNU GCC Compiler Select the toolchain executablesaba

There you can select which C compiler and C++ will use.

A tip Since you are participating in an Olympics is to take a look at this Jetbrains tool: https://www.jetbrains.com/clion / . If you are a student you get a one-year leave (I think)

If you are using Linux, to check the summer just use $gcc version version

 1
Author: apolzek, 2019-04-29 01:34:21