yum install centos-release-scl-rh
yum install devtoolset-3-gcc devtoolset-3-gcc-c++
update-alternatives --install /usr/bin/gcc-4.9 gcc-4.9 /opt/rh/devtoolset-3/root/usr/bin/gcc 10
update-alternatives --install /usr/bin/g++-4.9 g++-4.9 /opt/rh/devtoolset-3/root/usr/bin/g++ 10
Answer from Lars Bilke on Stack Overflow
Top answer
1 of 4
22
yum install centos-release-scl-rh
yum install devtoolset-3-gcc devtoolset-3-gcc-c++
update-alternatives --install /usr/bin/gcc-4.9 gcc-4.9 /opt/rh/devtoolset-3/root/usr/bin/gcc 10
update-alternatives --install /usr/bin/g++-4.9 g++-4.9 /opt/rh/devtoolset-3/root/usr/bin/g++ 10
2 of 4
21

For installing the system compilers gcc, g++, the install command is # yum install gcc-c++ → Provides version 4.8.5 : /usr/bin/{ gcc, g++ }.

Other options: 1. gcc53-c++-5.3.0-1.el6.x86_64.rpm → https://drive.google.com/file/d/0B7S255p3kFXNRm9FVnZYUnhyZzg/view?usp=sharing&resourcekey=0-1N6zQa6Sbl_WycG1O9I7JA : Download and install : # cd Downloads/ && yum install ./gcc53-c++-5.3.0-1.el6.x86_64.rpm ..... Provides /usr/bin/{gcc53, g++53}.

  1. The devtoolset´s : https://www.softwarecollections.org/en/scls/rhscl/devtoolset-6/ → # yum-config-manager --enable rhel-server-rhscl-7-rpms

Install gcc, g++ version 4.9.2 : # yum install devtoolset-3-gcc-c++

Note : You can have as many gcc/g++ versions as you want, installed at the same time. ( The system compilers are a must.)


  1. gcc49-c++-4.9.3-1.el6.x86_64.rpm https://drive.google.com/file/d/1Pwq1ua80dGM72i7rpDNAIIdfcR1WK-hG/view?usp=sharing → Provides /usr/bin/{gcc49, g++49}.

  1. gcc63-c++-6.3.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1t4WrgvpEP-6_NN3qMJhz9MS3CJhHrHKc/view?usp=sharing → Provides /usr/bin/{gcc63, g++63}.

  2. gcc45-c++-4.5.4-1.el7.x86_64.rpm https://drive.google.com/file/d/15aRg-BPhuyaEyZA9Jy-iAyC21_pwN7nD/view?usp=sharing → Provides /usr/bin/{gcc45, g++45, gfortran45}

  3. gcc42-c++-4.2.4-1.el6.x86_64.rpm https://drive.google.com/file/d/1eYWk6Nd63xeqqAUoJldNWRuwEGO6cAyv/view?usp=sharing → Provides /usr/bin/{gcc42, g++42}


  1. gcc73-c++-7.3.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1PgwCP5tu8D0EJbJVTqJd7Vg8dJ4l4noi/view?usp=sharing → Provides /usr/bin/{gcc73, g++73}

  2. gcc48-c++-4.8.5-1.el6.x86_64.rpm https://drive.google.com/file/d/1w6fW6oSflDDYZt_cOpGj3QMEmzUC8Q9L/view?usp=sharing → Provides /usr/bin/{gcc48, g++48, gfortran48}

  3. gcc84-c++-8.4.0-1.el7.x86_64.rpm https://drive.google.com/file/d/1xgFtsiDi2uiB1B0AcOaSpxVizzET-pJf/view?usp=sharing → Provides /usr/bin/{gcc84, g++84, gfortran84}

🌐
GitHub
gist.github.com › craigminihan › b23c06afd9073ec32e0c
Build GCC 4.9.2 for C/C++ on CentOS 7 · GitHub
I wanted to install ZNC i am using Centos 6 64BIT... Please help me to fix this error. Thanks ... This is a bit silly, why not just --j. At least then no matter what hardware you have, make will use it to its capacity. unless doing other jobs, but this is a big job and will take hours with 4cpu. ... [root@Talesofmidigard gcc-4.9.2]# make -j 4 make: *** No targets specified and no makefile found.
🌐
GitHub
gist.github.com › 1duo › ebd12d742331ce82cf4b1523f4e48a82
Install GCC (GNU Compiler Collection) on CentOS 7. · GitHub
Install GCC (GNU Compiler Collection) on CentOS 7. Raw · centos.install.gcc.md · Install Dependencies · yum install -y libmpc-devel mpfr-devel gmp-devel · Download GCC from: curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O tar -xvf gcc-4.9.2.tar.bz2 && cd gcc-4.9.2 ·
🌐
Medium
medium.com › @zilch0 › gcc-install-gcc-4-9-4-on-centos-7-ce83f5240fe7
[gcc] compile and install gcc 4.9.4 on CentOS 7 - zilch0 - Medium
August 13, 2021 - [gcc] compile and install gcc 4.9.4 on CentOS 7 install dependencies yum update yum install -y glibc-static libstdc++-static yum install gcc gcc-c++ yum install bzip2 2. download gcc 4.9.4 source …
🌐
jdhao's digital space
jdhao.github.io › 2017 › 09 › 04 › install-gcc-newer-version-on-centos
How to Compile and Install Latest Version of GCC on CentOS 7 · jdhao's digital space
April 20, 2019 - mkdir gcc-5.4.0-build cd gcc-5.4.0-build ../gcc-5.4.0/configure --enable-languages=c,c++ --disable-multilib make -j$(nproc) && make install
🌐
Benjamin-berhault
benjamin-berhault.github.io › my_personal_blog › › post › 2018 › 06 › 22 › install-gcc-on-rhel-centos-7.html
Build and Install the Last GCC on RHEL/CentOS 7
June 22, 2018 - The default GCC that comes with the CentOS 7.2 is GCC 4.8.5 which does not support the complete C++11 standard, for example, it does not fully support regular expressions. In order to use regular expression functions, we need to install at least GCC 4.9.0.
🌐
Centos
cbs.centos.org › koji › buildinfo
devtoolset-3-gcc-4.9.2-6.2.el7 | Build Info | CentOS Community Build Service
October 5, 2017 - Main Site Links: · Summary · Packages · Builds · Tasks · Build Targets · Users · Hosts · Reports · Search
Find elsewhere
🌐
CentOS Repositories
centos.pkgs.org › 7 › centos-sclo-rh-x86_64 › devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm.html
devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm CentOS 7 Download
The devtoolset-3-gcc package contains the GNU Compiler Collection version 4.9. ... 2015-01-09 - Jakub Jelinek <jakub@redhat.com> 4.9.2-5 - update from 4.9 branch (#1149294, #1025729) - don't include libatomic and libitm packages on RHEL 7 (#1160176) - avoid file dependency in devtoolset-*-libstdc++-devel package (#1167957)
🌐
GitHub
github.com › zxlhhyccc › centos7-gcc4.9
GitHub - zxlhhyccc/centos7-gcc4.9 · GitHub
centos 查看操作系统版本信息主要有以下几种方式: · a、通过 cat /proc/version 、uname · b、通过cat /etc/issue 、cat /etc/redhat-release · c、查看64位还是32位: · getconf LONG_BIT · d、使用 file /bin/ls · 使用 file /bin/ls · 先安装gcc、g++编译器 · yum install gcc · yum install gcc-c++ bzip2 lbzip2 · gcc:4.8.5 · 1、下载源码 · wget http://ftp.gnu.org/gnu/gcc/gcc-4.9.4/gcc-4.9.4.tar.bz2(如果需安装其他版本修改版本号即可) ·
Author   zxlhhyccc
🌐
GitHub
gist.github.com › nchaigne › ad06bc867f911a3c0d32939f1e930a11
Building GCC 9.2.0 on CentOS 7 · GitHub
CentOS 7 distribution (as well ... suitable to your compilation requirements. For example, C11 - which supersedes C99 - is fully supported only starting from GCC 4.9)....
Top answer
1 of 1
1

I have searched a lot for this error. Since no one answer, I answer myself, in case someone else has the same error. In conclusion, this is an error related to a variable called pthread_mutex_t. The definition and the initialization of this variable are incompatible.

First, check the location of pthread.h and pthreadtypes.h

locate pthread.h
locate pthreadtypes.h

In my case, I have two pthread.h files in different locations. Usually, the one under /usr/include is the file used during the compiling process. check the definition of PTHREAD_MUTEX_INITIALIZER. It should be like:

{{0, 0, 0, 0, 0, 0, {0, 0}}}

or a definition with #ifdef, but they are almost the same thing.

Then check the pthreadtypes.h. Usually, it is under /usr/include/bits. Find the definition of pthread_mutex_t. One version (ver1.0) maybe looks like this:

typedef union

{

  struct __pthread_mutex_s __data;

  char __size[__SIZEOF_PTHREAD_MUTEX_T];

  long int __align;

} pthread_mutex_t;

Another version (ver2.0):

typedef union

{

  struct __pthread_mutex_s

  {

    int __lock;

    unsigned int __count;

    int __owner;

#if __WORDSIZE == 64

    unsigned int __nusers;

#endif

    /* KIND must stay at this position in the structure to maintain

       binary compatibility.  */

    int __kind;

#if __WORDSIZE == 64

    int __spins;

    __pthread_list_t __list;

# define __PTHREAD_MUTEX_HAVE_PREV 1

#else

    unsigned int __nusers;

    __extension__ union

    {

      int __spins;

      __pthread_slist_t __list;

    };

#endif

  } __data;

  char __size[__SIZEOF_PTHREAD_MUTEX_T];

  long int __align;

} pthread_mutex_t;

You can see that the second one is much longer, and define a struct with '{}' in the union. That's why the error information keep saying cannot convert ‘’ to ‘short int’ in initialization. The reason is that the PTHREAD_MUTEX_INITIALIZER initialized the pthread_mutex_t with {} in the union. However, if you have the definition that looks like ver1.0, then here is the conflict. Then you may just replace the definition with ver2.0.

This may also be related to your GNU version. The ver1.0 definition seems for a newer version.

🌐
Bits and Dragons
bitsanddragons.wordpress.com › 2017 › 07 › 06 › install-simple-2-5-therefore-cmake-3-8-and-gcc-4-9-2-on-cent-os-7
Install Simple-2.5 (therefore cmake-3.8 and gcc-4.9.2) on Cent OS 7 | Bits and Dragons
March 7, 2018 - /usr/local/simple2.5 ## > cd build/ /usr/local/simple2.5/build ## > module load cmake-3.8.2 /usr/local/simple2.5/build ## > cmake ../ -- The Fortran compiler identification is GNU 4.8.5 -- The C compiler identification is GNU 4.8.5 ... CMake Error at cmake/SimpleFortranOptions.cmake:146 (message): SIMPLE requires gfortran 4.9 to 5.4 · We need another gfortran also. I follow what we found on github, then I try to make a module that should overwrite the default gcc. But it doesn’t seem somehow to work, or I don’t manage to install it properly. When I type gcc –version or similar, I still
🌐
Remi's RPM Repository
rpms.remirepo.net › rpmphp › zoom.php
Packages in Fedora / RHEL / CentOS / EPEL - Package: gcc
Show more informations from pkgdb · The Fedora Project is maintained and driven by the community and sponsored by Red Hat. This is a community maintained site. Red Hat is not responsible for content
Top answer
1 of 2
16

I've confirmed that you can upgrade gcc from the default version 4.8 on centOS 7.

First, we need to install "Software Collections" in order to access some of the community packages including gcc v7

  • sudo yum install -y centos-release-scl

Next, we want to install a developer toolset. Depending on your needs, you may want a different devtoolset. Here I'm targeting 7:

  • sudo yum install -y devtoolset-7

Finally, you'll want to change over to gcc 7 as your default, launch a new shell session with the scl tool:

  • scl enable devtoolset-7 bash
2 of 2
1

Enable the software collection in the answer is only effective in the current shell. The scl utility will create a "child-shell" that set the PATH variables properly, so that in the new child-shell, the enabled software collections will be firstly searched. These settings obviously only take effective temporarily in the current shell.

To make it permanently effective, add the command, source /opt/rh/devtoolset-7/enable to the user's profile (~/.bash_profile or ~/.bashrc for RHEL based OS, like CentOS 7). Then, start a new shell and you will have the right tools available.

After execute scl enable devtoolset-7 bash, you will need to execute exit twice to exit the opened shell window, which verifies that the scl command created a new shell instance as a child process. There might be side-effect with creating a child-shell, so do not put this command in the ~/.bashrc profile, otherwise it will repeatedly create child-shell (non-login shell) as each shell will load the profile, resulting in a endless recursive loop. Put it in ~/.bash_profile, it will be loaded for only once (for the login shell), but you will need to exit twice every time.

But for development purpose, scl enable devtoolset-7 bash would be preferred, as you can exit the created child-shell, and then switch between different versions of the same software.


More details about the GCC version in python terminal:

The version info of the built-in Python in CentOS 7:

[root@conda condabuilder]# python
Python 2.7.5 (default, Nov 16 2020, 22:23:17) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

The version info of the user installed (via conda) Python on a system even without higher version of GCC installed:

[root@conda condabuilder]# conda activate jupyter
(jupyter) [root@conda condabuilder]# python -VV
Python 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:20:04) [GCC 11.3.0]

From the results, we can see that the GCC version contained in Python's version info is not related to the system's GCC. The system's default Python (2.7.5) should have been compiled with the GCC version distributed with CentOS 7, so the version info show the same GCC version. But for user installed python, the GCC version info actually depends on what version of GCC is used for building and packging the python binary.

🌐
GitHub
gist.github.com › goldsborough › d466f43e8ffc948ff92de7486c5216d6
Instructions for installing GCC >= 4.9 for PyTorch Extensions · GitHub
# CentOS 7 sudo yum install centos-release-scl sudo yum install devtoolset-7-gcc* scl enable devtoolset-7 bash which gcc gcc --version ... Hope it helps. ... That worked for me-- thanks!! ... $ conda https://anaconda.org/brown-data-science/gcc/5.4.0/download/linux-64/gcc-5.4.0-0.tar.bz2 usage: conda [-h] [-V] command ...