由于CESM运行需要perl5,本来使用的是系统CentOS7自带的perl5,但版本较低,所以这里做一个升级,记录一下。
设置环境:
export CC=icc
export CXX=icpc
export CPP='icc -E'
export CXXCPP='icpc -E'
export CFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export CXXFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export CPPFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export F77=ifort
export FC=ifort
export FFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export FCLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
解压源码压缩包
tar -xvf perl-5.38.2.tar.gz
进入源码文件夹
cd perl-5.38.2
./Configure -des -Dusethreads -Dprefix=/home/LIBRARIES/perl
make
Making IO (all)
make[1]: Entering directory `/users/rmi1/build/perl-5.12.0/dist/IO'
make[1]: Leaving directory `/users/rmi1/build/perl-5.12.0/dist/IO'
Making all in dist/IO
make all PERL_CORE=1 LIBPERL_A=libperl.a LINKTYPE=dynamic
make[1]: Entering directory `/users/rmi1/build/perl-5.12.0/dist/IO'
cc -c -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"1.25_02\" -DXS_VERSION=\"1.25_02\" -fPIC "-I../.." IO.c
IO.xs: In function ‘XS_IO__Poll__poll’:
IO.xs:249: error: invalid application of ‘sizeof’ to incomplete type ‘struct pollfd’
IO.xs:253: error: invalid use of undefined type ‘struct pollfd’
IO.xs:253: error: dereferencing pointer to incomplete type
IO.xs:255: error: invalid use of undefined type ‘struct pollfd’
IO.xs:255: error: dereferencing pointer to incomplete type
IO.xs:257: error: invalid use of undefined type ‘struct pollfd’
IO.xs:257: error: dereferencing pointer to incomplete type
IO.xs:261: error: invalid use of undefined type ‘struct pollfd’
IO.xs:261: error: dereferencing pointer to incomplete type
IO.xs:262: error: invalid use of undefined type ‘struct pollfd’
IO.xs:262: error: dereferencing pointer to incomplete type
make[1]: *** [IO.o] Error 1
make[1]: Leaving directory `/users/rmi1/build/perl-5.12.0/dist/IO'
Unsuccessful make(dist/IO): code=512 at make_ext.pl line 449.
make: *** [lib/auto/IO/IO.so] Error 2
参考Make error when compiling Perl 5.12.1 (RHEL 5.5)找到解决办法:
首先检查一下:
printenv C_INCLUDE_PATH
printenv CPATH
如果有路径输出则设置:
unset C_INCLUDE_PATH
unset CPATH
重新make继续安装可解决问题
make
make test
make install
make install 后设置环境变量:
export PATH=/home/LIBRARIES/perl/bin:$PATH
export LD_LIBRARY_PATH=/home/LIBRARIES/perl/lib/5.38.2:$LD_LIBRARY_PATH
export LIBRARY_PATH=/home/LIBRARIES/perl/lib/5.38.2:$LIBRARY_PATH
export PERL5LIB=/home/LIBRARIES/perl5/lib/perl5
export PERL_LOCAL_LIB_ROOT=/home/LIBRARIES/perl5
export PERL_MB_OPT="--install_base /home/LIBRARIES/perl5"
export PERL_MM_OPT="INSTALL_BASE=/home/LIBRARIES/perl5"
检查版本
perl --version
wget http://xrl.us/cpanm
chmod +x cpanm
记得改下cpanm里面的:
#!/usr/bin/env perl
改成你自己的目录:
#!/home/LIBRARIES/perl/bin/perl
安装App::cpanminus:
curl -L https://cpanmin.us | perl - App::cpanminus
或者使用
wget -O - https://cpanmin.us | perl - App::cpanminus
# 下载源码压缩包
wget 'http://xmlsoft.org/sources/libxml2-2.9.10.tar.gz'
# 解压源码压缩包
tar -xf libxml2-2.9.10.tar.gz
# 进入源码文件夹
cd libxml2-2.9.10
./configure --prefix=/home/LIBRARIES/libxml2 --without-python
make
make install
cpanm Alien::LibXML
cpanm Alien::Libxml2
# XML::LibXML依赖于 XML::SAX
cpanm XML::SAX
cpanm XML::LibXML
查看已经安装哪些perl模块
instmodsh
l
q
[1] Linux | 安装perl
[2] CESM2——环境搭建:perl5 | 码农家园
[3] CESM移植记录_cesm 安装-CSDN博客
[4] Make error when compiling Perl 5.12.1 (RHEL 5.5)
[5] Linux如何安装并配置libxml2库?解决“libxml2 not found“问题-CSDN博客
[6] CESM2.1.3 移植记录