Fatal error: stdatomic. H: no such file or directory
Under Linux, errors are reported when compiling the source code using gcc
fatal error: stdatomic.h: No such file or directory
#include <stdatomic.h>
^
compilation terminated.
The reason is that the version of GCC 4.8 is too low and requires a higher version of GCC. How to safely upgrade the GCC version?
The devtoolset package can be installed through CentOS release SCL source
yum install centos-release-scl
yum install devtoolset-8
Or add your own source to install it (I’ll take centos7 as an example)
vi /etc/yum.repos.d/CentOS-SCLo-scl.repo
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/rh/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Activate the GCC version to make it effective
scl enable devtoolset-8 bash
or
source /opt/rh/devtoolset-8/enable
At this time, you can see through the GCC — version command that the GCC version has changed to 8.X.x. it is worth noting that this only takes effect in the current bash. If it needs to take effect permanently, you can add environment variables yourself.