centos c++环境配置
# ggml.c:98:23: fatal error: stdatomic.h: No such file or directory
gcc 4.8 的漏洞,在gcc 4.9已经修复
1
# gcc 4.9安装
# https://blog.csdn.net/fwb330198372/article/details/99636375
下载gcc安装文件(第一个镜像较快,不行可以尝试第二个):
wget https://mirrors.sjtug.sjtu.edu.cn/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.gz
wget https://ftp.gnu.org/gnu/gcc/gcc-4.9.0/gcc-4.9.0.tar.gz
安装C和C++的静态库: yum install -y glibc-static libstdc++-static
安装旧版本的gcc、c++编译器:yum install gcc gcc-c++
解压安装包:tar -zxvf gcc-4.9.0.tar.gz
切到目录里:cd gcc-4.9.0
安装需要用的到解压工具:yum install bzip2
下载一些必备的依赖程序:./contrib/download_prerequisites
编译和安装
./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j4
make install
检查是否安装完成:gcc -v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# gcc12安装
# 解决 stdatomic.h问题
sudo yum install libmpc-devel mpfr-devel gmp-devel
# current latest gcc version
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-12.2.0/gcc-12.2.0.tar.gz -O
tar xvf gcc-12.2.0.tar.gz
cd gcc-12.2.0
./configure --disable-multilib --enable-languages=c,c++
# change -j <cores_num> if you have more cpu cores for building be faster
make -j 4
make install
# 重要
export CC=gcc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 参考
上次更新: 2023-09-07 10:57:55