很快速的記下步驟:
一、安裝 zlib1.2.5
./configure --prefix=/usr/local/zlib --shared make make install註:如果 --prefix=/usr/local/zlib 是讓zlib裝在 /usr/local/zlib 資料夾中。這樣裝的好處是方便管理,缺點是 lib 與 includ 所在地要另外告知系統(就是讓系統知道他們被放在/usr/local/zlib 中。通常我的作法是寫一個script放在/etc/profile.d中,內容如下:
#! /bin/bash ZLIBHOME=/usr/local/zlib if [ -z "${LIBRARY_PATH}" ] then LIBRARY_PATH="$ZLIBHOME/lib" export LIBRARY_PATH else LIBRARY_PATH="$ZLIBHOME/lib:${LIBRARY_PATH}" export LIBRARY_PATH fi if [ -z "${LD_LIBRARY_PATH}" ] then LD_LIBRARY_PATH="$ZLIBHOME/lib" export LD_LIBRARY_PATH else LD_LIBRARY_PATH="$ZLIBHOME/lib:${LD_LIBRARY_PATH}" export LD_LIBRARY_PATH fi安裝szip-2.1
http://www.hdfgroup.org/ftp/lib-external/szip/2.1/src/szip-2.1.tar.gz tar zxvf szip-2.1.tar.gz cd szip export F77=ifort ./configure --prefix=/usr/local/szip make all make install二、安裝 hdf5 同zlib,如果我們不是裝在預設的資料夾,就需要告訴系統lib與includ放哪。拿上面的script一下即可。
export FC=ifort ./configure --prefix=/usr/local/hdf5 --enable-fortran --enable-hl --enable-shared --with-szlib=/usr/local/szip --with-zlib=/usr/local/zlib make make check make install make check-install
三、安裝libjpeg (jpge-6b) 原來,hdf4和hdf5是不相容的,衛星資料用的是hdf4,所以來裝一下hdf4,上面的libjpeg與szip就是為了這個hdf4裝的,請注意路徑是否與下面的設定一致。 在安裝hdf4之前,還得先裝libjpeg (jpge-6b)
wget http://www.hdfgroup.org/ftp/lib-external/jpeg/src/jpegsrc.v6b.tar.gz tar zxvf jpegsrc.v6b.tar.gz cd jpeg-6b export F77=ifort ./configure --prefix=/usr/local/libjpeg make all # 需要自行新增資料夾… mkdir /usr/local/libjpeg/bin mkdir /usr/local/libjpeg/man mkdir /usr/local/libjpeg/man/man1 make install mkdir /usr/local/libjpeg/include make install-headers mkdir /usr/local/libjpeg/lib make install-lib四、安裝 hdf4
#因為gdal要新版,epel裏的太舊,所以要自己裝,重點是,如果這個 hdf4 打算讓gdal用,就必需加上下面三行 export CFLAGS="-fPIC" export CXXFLAGS="-fPIC" export LIBS="-lm" export F77=ifort ./configure --prefix=/usr/local/hdf4 --with-szlib=/usr/local/szip --disable-netcdf --disable-fortran --enable-shared #./configure --prefix=/usr/local/hdf4 --with-zlib=/usr/local/zlib --with-szlib=/usr/local/szip --with-jpeg=/usr/local/libjpeg --enable-fortran make make check make install # 因為hdf4的bin裏也有叫做ncdump 與ncgen的執行檔,和netcdf取同樣名子,所以把它改掉。 cd /usr/local/hdf4/bin mv ncdump h4dump mv ncgen h4gen
四、安裝 netcdf 4.3.1.1 (C) 與 netcdf-4.2 (fortran)
注意,自4.2版之後,fortran c c++分開,要先裝c版,再裝fortran 版 CPPFLAGS="-I/usr/local/hdf5/include -I/usr/local/zlib/include" LDFLAGS="-L/usr/local/hdf5/lib -L/usr/local/zlib/lib"
所以改成下面指令
yum install libcurl-devel.x86_64 wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.3.1.1.tar.gz tar zxvf netcdf-4.3.1.1.tar.gz cd netcdf-4.3.1.1 ./configure FC=ifort F77=ifort F90=ifort CXX=g++ --prefix=/usr/local/netcdf --enable-netcdf4 --enable-shared --enable-dap CPPFLAGS="-I/usr/local/hdf5/include -I/usr/local/zlib/include" LDFLAGS="-L/usr/local/hdf5/lib -L/usr/local/zlib/lib" make make check make install wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-fortran-4.2.tar.gz tar zxvf netcdf-fortran-4.2.tar.gz cd netcdf-fortran-4.2 #./configure FC=ifort F77=ifort F90=ifort CXX=g++ --prefix=/usr/local/netcdf --enable-shared CPPFLAGS="-I/usr/local/netcdf/include -I/usr/local/hdf5/include -I/usr/local/zlib/include" LDFLAGS="-L/usr/local/hdf5/lib -L/usr/local/zlib/lib -L/usr/local/netcdf/lib" #因為系也另外裝了netcdf,所以要注意LD_LIBRARY_PATH裏的順序,我們裝的netcdf要放前可,不然會用到系統裝的,會有問題。 #所以如果用上面的方法出現錯誤,可能是這個原因,那就改用下面的方法 CPPFLAGS="-I/usr/local/netcdf/include -I/usr/local/hdf5/include -I/usr/local/zlib/include" \ LD_LIBRARY_PATH=/usr/local/hdf5/lib:/usr/local/zlib/lib:/usr/local/netcdf/lib:${LD_LIBRARY_PATH} \ LDFLAGS="-L/usr/local/hdf5/lib -L/usr/local/zlib/lib -L/usr/local/netcdf/lib" \ LIBS="-lnetcdf -lhdf5_hl -lhdf5 -lz -lcurl" \ ./configure FC=ifort F77=ifort F90=ifort CXX=g++ --prefix=/usr/local/netcdf --enable-shared --prefix=/usr/local/netcdf安裝 netcdf 4.1.3
注意,自4.1.3版之後,不支援--with-hdf5=/usr/local/hdf5,取而代之的是改用
CPPFLAGS=-I/usr/local/hdf5/include LDFLAGS=-L/usr/local/hdf5/lib
所以改成下面指令
yum install curl-devel.x86_64 ./configure FC=ifort F77=ifort F90=ifort CXX=g++ --prefix=/usr/local/netcdf --enable-netcdf4 --enable-shared --enable-dap CPPFLAGS=-I/usr/local/hdf5/include LDFLAGS=-L/usr/local/hdf5/lib make make check make install
安裝 netcdf 4.1.2
./configure FC=ifort F77=ifort F90=ifort CXX=g++ --prefix=/usr/local/netcdf --enable-netcdf4 --enable-shared --with-hdf5=/usr/local/hdf5 make make check make install
沒有留言:
張貼留言