程序编译

编译程序 二:perl篇

2019-11-26 00:51:38 admin 531


如何在北京大学北极星高性能计算平台中,安装自定义版本的perl的编译:

1、下载:https://www.perl.org/get.html 

2、解压:

[test_pkuhpc@login12 2019test]$ tar -xvf /gpfs1/web-q/linux-shell/conf/perl-5.30.1.tar.gz  

3、进入目录

[test_pkuhpc@login12 2019test]$ cd perl-5.30.1/

4、第一件事就是看看configure等文件的帮助**

[test_pkuhpc@login12 perl-5.30.1]$ ./Configure --help  ##注意这里首字母大写

图片关键词

5、因为是自定义目录安装,所以上图中红色圈的选项是需要的 -Dprefix=/opt/perl5

6、创建文件夹:

[test_pkuhpc@login12 perl-5.30.1]$ mkdir /lustre1/test_pkuhpc/perl-5.30.1

7、配置检测环境:

[test_pkuhpc@login12 perl-5.30.1]$ export PERL5LIB=/lustre1/test_pkuhpc/perl-5.30.1/lib ##这部很重要

[test_pkuhpc@login12 perl-5.30.1]$ ./Configure  -Dprefix=/lustre1/test_pkuhpc/perl-5.30.1

其他都默认:

[/lustre1/test_pkuhpc/perl-5.30.1/bin] 

Directory /lustre1/test_pkuhpc/perl-5.30.1/bin doesn't exist.  Use that name anyway?

[n] y ##这步选择y

8、编译和测试

[test_pkuhpc@login12 perl-5.30.1]$ make 

[test_pkuhpc@login12 perl-5.30.1]$ make test

9、安装:

[test_pkuhpc@login12 perl-5.30.1]$ make install

10、用vi添加source文件如下

[test_pkuhpc@login12 perl-5.30.1]$ cat ~/perl5.30.1.sh

#!/bin/bash

perlver=perl-5.30.1

if [ ! -d "/home/$USER/perl5/$perlver/" ];then

mkdir -p /home/$USER/perl5/perl5.28.2/

fi 

export PERL_MB_OPT="--install_base \"/home/$USER/perl5/$perlver\"";

export PERL_MM_OPT="INSTALL_BASE=/home/$USER/perl5/$perlver"

export PATH=/lustre1/test_pkuhpc/$perlver/bin:$PATH

export PERL5LIB=/lustre1/test_pkuhpc/$perlver/lib/5.30.1:/lustre1/test_pkuhpc/$perlver/lib/5.30.1/x86_64-linux/

11、测试安装包

[test_pkuhpc@login12 perl-5.30.1]$ cpan xml

Loading internal logger. Log::Log4perl recommended for better logging

CPAN.pm requires configuration, but most of it can be done automatically.

If you answer 'no' below, you will enter an interactive dialog for each

configuration option instead.

Would you like to configure as much as possible automatically? [yes] 

##这里选yes,所以直接回车


**注释:

configure、Makefile.in一般是项目管理器自动生成的,这依赖于两个开发工具:

autoconf:生成configure脚本文件;

autoconf需要结合一个配置文件来和其它命令生成configure脚本;这个配置文件告诉autoconf当前代码有哪些特性、指定哪些安装路径等,而后才能生成configure脚本;

automake:生成Makefile.in模板文件;

automake也要结合一个文件,这个指明有多少程序文件、它们的依赖关系是什么、以及使用哪一种版本的编译器等,而后才能生成Makefile.in;

Note:在安装之前查看INSTALL和README文件查看安装方法,因为不同程序包安装步骤不一样,有的程序包不需要configure,直接make后执行make install;而


首页
资源&收费
集群
成果
问答