Gcc compiler

From Klaus' wiki
Revision as of 09:49, 3 February 2021 by Klaus (Talk | contribs)

Jump to: navigation, search

The default gcc compiler collection that comes with Centos 7 is a version 4.8.5 from 2015. It is OK for the most of our educational work. But in order to be able to use the latest version of especially C++ language it could be handy to upgrade the GCC Compiler Collection.

NOTE: Since time of writing a version 8 has been released. So if you want the latest substitute 7 with 8 in the description below.

Download and install

Execute this:

[~] $  sudo yum install centos-release-scl

This opens for a repository that contains a newer version of the development tools.

Next execute:

[~] $ sudo yum install devtoolset-7

Using the new toolchain?

Now in order to use the new toolchain you must run a small utility program, that sets up the environment. Try execute

[~] $ scl enable devtoolset-7 bash

This will start a new bash shell with the new toolchain enabled.

In order to start Eclipse using the toolchain execute this:

[~] $ scl enable devtoolset-7 /opt/eclipses/eclipse-cdt/eclipse

provided that you have installed your version of Eclipse in the above shown path - if not customise to your needs.

Finally, if you want to permanently use the new toolchain you can edit the icon in the start menu.

Eclipse showing false errors

Switching to the new compiler may end up in having a lot of errors shown in the source code. But if you clean your project and rebuild it it may build perfectly without errors and yet still errors are shown in the editor. It is the indexer, that Eclipse uses in order to help you.

Follow these instructions and you should have rebuild the indexer files:

  • Window / Preferences / C/C++ / Indexer.
  • uncheck "Enable indexer" ->>OK
  • rebuild all, may show lots of errors
  • check "Enable indexer" ->>OK
  • clean and rebuild al