Change compiler settings in Codeblocks

Asked

Viewed 1,132 times

2

I will participate in a clear programming and 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 -o source executable. c

C++: G++ compiler version 8.2 or higher - Command line: g++ -Std=C++11 -lm -O2 -Static -o source executable.cpp

How do I set it up? And how do I set it up Debugger for that compiler version?

2 answers

1

Hello, using Codeblock you must enter

Menubar Settings->Compiler and Debugger Select GNU GCC Compiler Select the executed Toolchain

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

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

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

1


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:

inserir a descrição da imagem aqui

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

inserir a descrição da imagem aqui

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

inserir a descrição da imagem aqui

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:

inserir a descrição da imagem aqui

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:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.