0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GMT5.4.5をインストールする(CentOS Stream9)

Last updated at Posted at 2024-06-01

はじめに

GMT5,GMT6で互換性がないため、GMT5で書かれたスクリプトがGMT6では使用できない。CentOS Stream9のパッケージ管理ソフトではGMT6がセットされるため、GMT5の最終版の5.4.5をコンパイルする必要があります。(Anacondaでも一応可であるが、やりたくない。)

方針

  • GMTプログラム以外のデータや依存するプログラムについてはパッケージ管理ソフトで管理を行う。
  • 公式サイトのwikiにしたがうhttps://github.com/GenericMappingTools/gmt/wiki
  • /usr/local/gmt-5.4.5にプログラム一式を置くものとする。

GMTが依存しているプログラムのインストール

事前設定

詳細はhttps://docs.fedoraproject.org/en-US/epel/
EPEL,EPEL-NEXTリポジトリが入っていること、無効になっているCRBリポジトリが有効すること。

dnf config-manager --enable crb
dnf install epel-release epel-next-release
# リポジトリの存在と有効無効の確認
dnf repolist --all

こちらの# Install required dependencies# Install optional dependenciesをインストールする

dnf install cmake libcurl-devel netcdf-devel gdal-devel
dnf install ninja-build gdal pcre-devel fftw3-devel lapack-devel openblas-devel glib2-devel ghostscript

GMTのデータのインストール

dnf install gshhg-gmt-nc4 gshhg-gmt-nc4-full gshhg-gmt-nc4-high dcw-gmt

※gshhgは/usr/share/gshhg-gmt-nc4ディレクトリにデータが格納される。
※dcwは/usr/share/dcw-gmtディレクトリにデータが格納される。

GMTソースコードのダウンロード

wget https://github.com/GenericMappingTools/gmt/releases/download/5.4.5/gmt-5.4.5-src.tar.gz
tar -zxf gmt-5.4.5-src.tar.gz
cd gmt-5.4.5

GMTのコンパイル

README.cmakeを見て以下必要なオプションを追加(cmakeを使います)

cmakeファイルの修正

cp cmake/ConfigUserTemplate.cmake cmake/ConfigUser.cmake

cmake/ConfigUser.cmakeでデフォルトから一部を変える。
cmakeの-Dオプションで指定することも可能であるが、ここではConfigUser.cmakeですべての設定を決めることにする。

以下のようにコメントアウトを外して、修正し、追加した。

cmake/ConfigUser.cmake
set (CMAKE_INSTALL_PREFIX "/usr/local/gmt-5.4.5")
set (GMT_INSTALL_RELOCATABLE TRUE)
set (GMT_EXCLUDE_GDAL TRUE)
set (GMT_EXCLUDE_PCRE TRUE)
set (GMT_EXCLUDE_PCRE2 TRUE)
set (GMT_EXCLUDE_FFTW3 TRUE)
set (GMT_EXCLUDE_LAPACK TRUE)
set (GMT_EXCLUDE_ZLIB TRUE)
# CentOS Stream9の場合
set (GSHHG_ROOT "/usr/share/gshhg-gmt-nc4")
set (DCW_ROOT "/usr/share/dcw-gmt")
# gcc>=10の場合(Ubuntu22.04,CentOS Stream9は該当します。)
# <https://github.com/GenericMappingTools/gmt/issues/2493>
# <https://qiita.com/yasuhirokimura/items/d5337d73a016502b9d54>
# ConfigUser.cmakeに以下の項目を追加して古いバージョンで実行できるようにする。(対処療法)
set (CMAKE_C_FLAGS "-fcommon")

ソースコードの修正

glibc>=2.32で廃止となった項目を修正する。(Ubuntu22.04,CentOS Stream9は該当します。)
こちらにありました https://github.com/greenbone/gvmd/issues/1279

src/common_sighandler.cの190行

sys_siglist[sig_num] -> strsignal (sig_num)

に変更する。

実行

mkdir build
cd build
cmake ..
make -j8 # 8コアでコンパイル
sudo make -j8 install
make clean

GMTのパスを張る

最後に/usr/local/gmt-5.4.5/binにパスを張りましょう。

$ vi ~/.profile
$ vi ~/.bashrc
$ vi ~/.bash_profile
等
export PATH=/usr/local/gmt-5.4.5/bin:${PATH}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?