1 方案一:通过 EPEL 源安装(Centos 8)

1.1 安装 EPEL8 源

链接:https://grass.osgeo.org/download/linux/#GRASS-GIS-current

image-20230507202148758

安装 EPEL8 源步骤:参考链接:https://blog.csdn.net/Lcongming/article/details/115983236

  • 首先切换到yum仓库源的目录
1
cd /etc/yum.repos.d/
  • 创建文件
1
2
3
4
5
6
7
8
touch epel8.repo
# 文件内容如下:
[EPEL]
name=EPEL
baseurl=https://mirrors.cloud.tencent.com/epel/8/Everything/x86_64/
gpgcheck=0
# 需要确保这个链接能打开
# epel7用这个:https://mirrors.cloud.tencent.com/epel/7/x86_64/
  • 执行 yum repolist 读取查看结果,已经都可以读取了
1
yum repolist

image-20230507202627273

1.2 查看软件库中是否包含 GRASS

1
yum search grass

image-20230507202759087

1.3 安装 GRASS

1
yum install grass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
Error: Package: wxBase3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: grass-7.8.7-1.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: xerces-c-3.2.3-5.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: hdf-4.2.14-5.el8.x86_64 (EPEL)
Requires: libtirpc.so.3(TIRPC_0.3.0)(64bit)
Error: Package: wxGTK3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: grass-libs-7.8.7-1.el8.x86_64 (EPEL)
Requires: libpng16.so.16(PNG16_0)(64bit)
Error: Package: wxBase3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: PDAL-libs-2.1.0-8.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: wxBase3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libc.so.6(GLIBC_2.28)(64bit)
Error: Package: grass-7.8.7-1.el8.x86_64 (EPEL)
Requires: libm.so.6(GLIBC_2.27)(64bit)
Error: Package: wxGTK3-gl-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: grass-7.8.7-1.el8.x86_64 (EPEL)
Requires: libreadline.so.7()(64bit)
Error: Package: PDAL-libs-2.1.0-8.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: python3-wxpython4-4.0.7-13.el8.x86_64 (EPEL)
Requires: python3-wx-siplib-api(12)(x86-64) >= 12.7
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: python3-wxpython4-4.0.7-13.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: grass-libs-7.8.7-1.el8.x86_64 (EPEL)
Requires: libpng16.so.16()(64bit)
Error: Package: PDAL-libs-2.1.0-8.el8.x86_64 (EPEL)
Requires: libc.so.6(GLIBC_2.27)(64bit)
Error: Package: proj-6.3.2-4.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: PDAL-2.1.0-8.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: libbsd-0.11.7-2.el8.x86_64 (EPEL)
Requires: libc.so.6(GLIBC_2.25)(64bit)
Error: Package: python3-wxpython4-4.0.7-13.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libm.so.6(GLIBC_2.27)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libjson-c.so.4(JSONC_0.14)(64bit)
Error: Package: xerces-c-3.2.3-5.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: hdf5-1.10.5-4.el8.x86_64 (EPEL)
Requires: libm.so.6(GLIBC_2.27)(64bit)
Error: Package: wxGTK3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libpng16.so.16(PNG16_0)(64bit)
Error: Package: hdf5-1.10.5-4.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: PDAL-2.1.0-8.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: grass-libs-7.8.7-1.el8.x86_64 (EPEL)
Requires: libm.so.6(GLIBC_2.23)(64bit)
Error: Package: ogdi-4.1.0-1.el8.x86_64 (EPEL)
Requires: libtirpc.so.3()(64bit)
Error: Package: grass-7.8.7-1.el8.x86_64 (EPEL)
Requires: libpng16.so.16(PNG16_0)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libjson-c.so.4()(64bit)
Error: Package: wxGTK3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: PDAL-libs-2.1.0-8.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.22)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libpoppler.so.104()(64bit)
Error: Package: xerces-c-3.2.3-5.el8.x86_64 (EPEL)
Requires: libm.so.6(GLIBC_2.27)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: python3-wxpython4-4.0.7-13.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: wxGTK3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: grass-7.8.7-1.el8.x86_64 (EPEL)
Requires: python3-dateutil
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libcfitsio.so.7()(64bit)
Available: cfitsio-3.47-1.el8.x86_64 (EPEL)
libcfitsio.so.7()(64bit)
Installed: cfitsio-3.370-10.el7.x86_64 (@epel)
~libcfitsio.so.2()(64bit)
Error: Package: hdf-4.2.14-5.el8.x86_64 (EPEL)
Requires: libtirpc.so.3()(64bit)
Error: Package: proj-6.3.2-4.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: netcdf-4.7.0-2.el8.x86_64 (EPEL)
Requires: libtirpc.so.3()(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libdap.so.25()(64bit)
Error: Package: ogdi-4.1.0-1.el8.x86_64 (EPEL)
Requires: libtirpc.so.3(TIRPC_0.3.0)(64bit)
Error: Package: PDAL-libs-2.1.0-8.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: python3-wxpython4-4.0.7-13.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.8)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libpng16.so.16(PNG16_0)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libgif.so.7()(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libjasper.so.4()(64bit)
Error: Package: proj-epsg-4.8.0-4.el7.x86_64 (@epel)
Requires: proj = 4.8.0-4.el7
Removing: proj-4.8.0-4.el7.x86_64 (@epel)
proj = 4.8.0-4.el7
Updated By: proj-6.3.2-4.el8.x86_64 (EPEL)
proj = 6.3.2-4.el8
Error: Package: proj-nad-4.8.0-4.el7.x86_64 (@epel)
Requires: proj = 4.8.0-4.el7
Removing: proj-4.8.0-4.el7.x86_64 (@epel)
proj = 4.8.0-4.el7
Updated By: proj-6.3.2-4.el8.x86_64 (EPEL)
proj = 6.3.2-4.el8
Error: Package: grass-7.8.7-1.el8.x86_64 (EPEL)
Requires: libhistory.so.7()(64bit)
Error: Package: wxBase3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: gdal-libs-3.0.4-11.el8.x86_64 (EPEL)
Requires: libpng16.so.16()(64bit)
Error: Package: arpack-3.7.0-1.el8.x86_64 (EPEL)
Requires: libm.so.6(GLIBC_2.27)(64bit)
Error: Package: proj-6.3.2-4.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit)
Error: Package: proj-6.3.2-4.el8.x86_64 (EPEL)
Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit)
Error: Package: grass-7.8.7-1.el8.x86_64 (EPEL)
Requires: libpng16.so.16()(64bit)
Error: Package: wxGTK3-3.0.4-11.el8.x86_64 (EPEL)
Requires: libpng16.so.16()(64bit)

直接 yum 安装 grass 会存在依赖错误的问题,先看报错缺的是什么包,然后通过rpm的方式先把缺的包装好,所有缺的包安装完毕后,就可以通过yum install grass完成grass的安装,缺的包可以在这个网站上找:https://pkgs.org/

image-20230507203155606

  • 假设缺的包是下面这个:

    image-20230507203400626

  • 点进去,查看这个包的下载地址:

image-20230507203411137

  • 然后通过rpm命令安装这个包:rpm -Uvh 包的URL
1
2
3
4
# rpm -Uvh 包的URL
rpm -Uvh https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/glibc-2.28-164.el8.x86_64.rpm
# 强制安装,忽略依赖错误
# rpm -Uvh https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/glibc-2.28-164.el8.x86_64.rpm --force --nodeps

2 方案二:源码编译安装

参考链接:https://www.zhihu.com/zvideo/1496911384683773952

  • 下载安装包
  • 解压并进入
  • 开始编译
1
./configure --prefix=/home/oge/oge-grass

疑难杂症

  • GRASS需要针对 zstd 进行编译和链接。查看您尝试的命令(yum install zstd-devel),我假设您使用的是RHEL/CentOS7。在CentOS存储库中没有zstd的包-您需要从EPEL安装它。它应该看起来像这样

image-20230508084941624

1
yum install libzstd-devel

image-20230508084900049

1
2
3
whereis gdal-config
# 然后再在编译时指定依赖的位置
./configure --with-gdal=/usr/local/bin/gdal-config --prefix=/home/oge/oge-grass

image-20230508090349691

1
yum install PNG-devel

image-20230508090437991

1
yum install fftw-devel

image-20230508090610207

1
yum install cairo-devel

image-20230508091746038

1
yum install freetype-devel

3 方案三: Docker镜像方式安装 (推荐)

image-20230508194802552

  • 创建容器