How to upgrade gcc 4.7.2 in centos 6.9 to gcc 4.8 - gcc

I am running centos version 6.9 and had installed gcc using command sudo yum install -y gcc gcc-c++ which installed gcc version 4.7.2. However i need to use gcc version 4.8.5. How do i upgrade gcc to the required version?

CentOS 6 does not come with GCC 4.7, so you must have installed something else.
You can upgrade to CentOS 7. This will give you GCC 4.8.5 (plus extensive backports, including at least one new backend). But the binaries you compile on CentOS 7 will not run on CentOS 6.
If you need just a newer GCC, and not version 4.8.5 exactly, you can use Developer Toolset. Version 7 gives you GCC 7. For C and C++ at least, the compiled code will run on any CentOS 6 system.

Related

Installing gcc 3.4.6 on Centos 7

We are working on building an application using gcc 3.4.6 and need to build on gcc 3.4.6 but dont want use a version of CentOS older then CentOS 7. Can gcc 3.4.6 be install on CentOS 7 ?

How to install older version of GCC on Windows 10

I need to install MinGW GCC 7.3 on my computer for a project. Downloaded and installed: C:\MinGW\bin\MingGW-get.exe. But when I run it, it only gives me the option to install the latest GCC v9.2.0. How do I download and install GCC v7.3 on my computer? Step-by-step directions appreciated.
Unless you specifically want the mingw.org toolchain, check out https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/. Currently there's v8.1.0, v7.3.0, v6.4.0 and v5.4.0. Other versions are available elsewhere.
Of you need to support an older C/C++ standard the -std= compiler flag may already help (e.g. -std=c99 for ISO 1999 C or -std=c++98 for ISO 1998 C++).
Note that GCC 7.3 is not the latest version of GCC 7. The latest GCC 7 release is version 7.5.0.
You can the Windows (MinGW-w64) version from: http://winlibs.com/
The online installer tool (first option on the page) allows you to do so.
https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe

g++: error: unrecognized '-std=c++17' (what is g++ version and how to install)

I am working on RHEL 7.5 and trying to compile a uWebSocket (This exaple) code. I clone the project and open it. When I start make on Makefile I got this error;
BroadcastingEchoServer uSockets/*.o -lz;
g++: error: unrecognized command line option '-std=c++17'
make: [examples] Error 1>
The main problem is -std=c++17 is not recognized. How can I control what c++ version I have (that 17 in the end) and how can I install required version.
gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thanks
RHEL is providing newer versions of GCC additionally using socalled Software Collections (SCL). In your case you could enable this repository (depending whether you have a workstation or a server subscription):
subscription-manager repos --enable rhel-server-rhscl-7-rpms
subscription-manager repos --enable rhel-workstation-rhscl-7-rpms
Afterwards you could install one (or multiple) of the following packages:
yum install devtoolset-6-gcc-c++ (GCC 6.3.1, until RHEL 7.7)
yum install devtoolset-7-gcc-c++ (GCC 7.3.1)
yum install devtoolset-8-gcc-c++ (GCC 8.3.1)
yum install devtoolset-9-gcc-c++ (GCC 9.3.1, since RHEL 7.7)
yum install devtoolset-10-gcc-c++ (GCC 10.2.1, since RHEL 7.9)
yum install devtoolset-11-gcc-c++ (GCC 11.2.1, since RHEL 7.9)
Note that you can install the whole devtoolset of a specific version using e.g. yum install devtoolset-11-toolchain. This might be needed (or not) depending on your specific usecase.
Once installed, run e.g. scl enable devtoolset-11 bash when you installed devtoolset-11-gcc-c++. Calling g++ will then lead to GCC 11.2.1. For scripts, using . /opt/rh/devtoolset-11/enable before using g++ might be more convenient.
If needed, see How can I make a Red Hat Software Collection persist after a reboot/logout? in the Red Hat Knowledgebase.
gcc (GCC) 4.8.5
C++17 is not supported by GCC v4.8.
C++17 is not supported by GCC v4.9.
C++17 is supported by GCC v5, but you need -std=c++1z:
The next revision of the ISO C++ standard, tentatively planned for 2017. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.
GCC v5 was released 2015 and they did not yet have time machines back then ;o)
Same applies to GCC v6 and GCC v7 (released 2016 and 2017).
C++17 is supported by GCC v8 by means of -std=c++17 (and by -std=c++1z which is deprecated since then).
For the GNU-C++ dialects, use -std=gnu++* instead of -std=c++*.
Hence for serious projects, you should use GCC v8 or newer.
Use:
yum install devtoolset-9-toolchain
scl enable devtoolset-9 bash

How to install two GCC versions for cuda 5.0 on centos7

I need to install cuda 5.0 in centos7 x64. But, I have a problem with GCC, as the current version installed is (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11).
What is the supported version of GCC for Cuda 5.0 and how to install this older GCC version with my actual compiler ((GCC) 4.8.5).
Thanks in advance
#talonmies has provided a list of maximum GCC version supported by different versions of CUDA. Specifically: CUDA 5.0 supports GCC up to 4.6 - and that's what you should install.
There's an answer here on SO which explains how to get GCC 4.6(.3) installed by building from sources. Essentially you need to build some libraries with any C compiler before you can build GCC itself.
Good luck.

Will app built with gcc 4.x on CentOS/RHEL 4.8 run on completely un-updated CentOS/RHEL 4?

We have a commercial application that we build on 32-bit CentOS 4.8 (equivalent to Red Hat Enterprise Linux (RHEL) 4 update 8.
The default gcc compiler is at 3.4.6
We are able to run our binary on both 32- and 64-bit CentOS/RHEL 4 and 5 including completely un-updated RHEL 4.
THE QUESTION: If we update to a newer gcc 4 version, will the binary still run on a completely un-updated RHEL 4
The newest gcc appears to be 4.5.1 and 4.4.5
(And yes there are customers who install the intial version, run on an isolated network with no Internet access, and NEVER update from the as-shipped version.)
This issue has arisen because we are now porting to 64-bit FreeBSD 8.1 for amd64 and the default gcc there is gcc 4.2.1
As long as you're compiling against the same runtime libraries (like glibc) you'll be fine.

Resources