Page 1 of 1

run a c++ program with c++11 support in older CentOS machine

Posted: 2018/08/27 13:25:48
by gane.prog
How to upgrade libstdc++-4.4.7 on CentOS 6.10 to libstdc++-4.8.5 on CentOS 6.10

I build my c++ program on CentOS 7.5 with libstdc++-4.8.5 for c++11 using features.

Now I have to run my program on CentOS 6.10 for production.


Can I install libstdc++-4.8.5-28.el7.i686 on CentOS 6.10 if not any other posibilities ?

Re: run a c++ program with c++11 support in older CentOS machine

Posted: 2018/08/27 17:51:46
by TrevorH
Build your program on CentOS 6 if that's where you want it to run. You cannot get the newer glibc etc onto CentOS 6 and if you could, it would be way way simpler just to update to CentOS 7 in the first place.

Re: run a c++ program with c++11 support in older CentOS machine

Posted: 2018/08/28 04:44:59
by chemal
Now I have to run my program on CentOS 6.10 for production.
Compile your source code on 6.10. You can choose from five devtoolsets offering gcc 4.8.2, 4.9.2, 5.3.1, 6.3.1, and 7.3.1, respectively. That should be enough C++11.

Re: run a c++ program with c++11 support in older CentOS machine

Posted: 2018/08/28 07:57:14
by jlehtone
The "devtoolsets" come from Software Collections (SCL).
To install (these) SCL packages, you need:

Code: Select all

yum install centos-release-scl-rh
There are currently only two devtoolset versions, the older ones have been removed:
devtoolset-6 and devtoolset-7

Available versions of g++ are thus:

Code: Select all

compat-gcc-34-c++.x86_64            3.4.6-19.el6   base
devtoolset-6-gcc-c++.x86_64         6.3.1-3.1.el6  centos-sclo-rh
devtoolset-7-gcc-c++.x86_64         7.3.1-5.10.el6 centos-sclo-rh
gcc-c++.x86_64                      4.4.7-23.el6   base
To get the devtoolset version, I do recommend:

Code: Select all

yum install devtoolset-7-toolchain
That pulls in the tools to do a build.

In order to do a build:

Code: Select all

scl enable devtoolset-7 bash
make
exit
The scl starts a command (bash) with environment, where devtoolset-7 tools are first in PATH.
The binaries ought to run in normal environment.