• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Perl模块安装

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Linux使用CPAN模块自动安装  

安装前需要先联上线,并且要取得root权限。  
perl -MCPAN -e shell

获得帮助  
cpan>h  

列出CPAN上所有模块的列表  
cpan>m  

根据关键字在CPAN上查找某个模块:

cpan[1]> i /scws/


安装模块  
cpan>install DBI  
自动完成DBI模块从下载到安装的全过程。  

退出  
cpan>q 

 

手动编译Perl模块

具体步骤:  1 安装编译器   2 设置编译器的环境变量   3 可能安装dmake
具体方法:

1. 首先要有个c编译器,推荐dev-cpp(开源免费的, http://umn.dl.sourceforge.net/sourceforge/dev-cpp/devcpp4990setup.exe  ),记得要下含有mingw的就是了(下载含有mingw的,因为这个版本的bin目录里有gcc.exe等工具).

1.1 安装好了编译器之后,要能在cmd中以命令方式运行的话,必须要设置环境变量, 在winxp中[我的电脑]->[属性]->[高级]->[环境变量]里设置,只需要在path里加个你路径,比如你的安装路径是c:\dev-cpp,那你就要加上c:\dev-cpp\bin (path中有很多其他的路径,之间记得用;隔开)弄完好,重启电脑,在cmd中运行gcc -v 显示出内容表示编译器安装成功,并且可以用命令行编译.

2. 编译步骤,在cpan上下载需要的模块,比如Win32::SerialPort,下载好了解压,在cmd中进入这个目录,就用常见的方法:
   perl Makefile.pl
   make 
   make test
   make install

2.1 需要注意几点
2.1.1 具体编译步骤应该先看下模块包内的readme
2.1.2 用的是dev-pp编译器,故用make,vc编译器好象是nmake
2.1.3 最重要的是,使用make很可能会出现错误,不能编译,找了很多原因,有高人介绍了解决办法,就是下载一个叫dmake的工具(

http://search.cpan.org/CPAN/authors/id/S/SH/SHAY/dmake-4.12-20090907-SHAY.zip

),下载后解压缩,将里面的dmake.exe和startup的文件夹一起复制到c:\dev-cpp\bin 里(因为这个目录注册到环境变量里的),之后安装改成:
   perl Makefile.pl
   dmake 
   dmake test
   dmake install

 

ref:

http://blog.csdn.net/runandrun/article/details/6010840

http://hi.baidu.com/opcbo/blog/item/07801e2a02dd9d195243c110.html

 

windows xp下perl cpan模块安装及问题解决

关于这个主题网上有些教程,对的,错的都有。如果将这些对的,错的方法都试一遍的话,你就会发现结果往往是令人郁闷的。对于习惯了windows的用户,perl MakeFile.PL、make、make install的标准3步操作和给出的提示犹如天书。
     现在我就将我尝试过的方法,以及出现的结果,最终的解决方法简介如下,整个过程以Coro模块为例子。
     所用的perl为:ActiveState perl 5.10
1,下载Coro模块,解压缩。目录中最好不要出现空格,中文字符,避免出现问题。
2,dos下进入该目录,运行命令:perl makefile.pl
3,注定是要失败的,因为该模块是xs模块。需要配置一个C/C++ compiler(C/c++编译器环境)。
    提示:It looks like you don't have a C compiler on your PATH, so you will not be able to compile C or XS extension modules.
4,有文章推荐用Microsoft visual c++ 2005 express edition 大小462M左右。下载,安装,还要运行vsvarsall.bat来设置环境变量,验证环境变量设置是否成功的方法:在dos下直接键入cl,然后按回车,如果返回该命令的一些提示,那就设置正确了。还要下载nmake.exe,运行nmake.exe,会生成两个文件:nmake15.exe和NMAKE.ERR。将这两个文件复制到perl安装目录的bin文件夹中。
5,运行步骤2的命令,然后运行命令:nmake。提示windows.h文件找不到,原来是需要SDK配合。哎,真烦,放弃了这条路。
6,卸载VC 2005。同时把环境变量path里不需要的一些路径给清理了。
7,下载DEV-C++ 5,大小只有10几M。
8,安装它,在命令行下输入:gcc -v 返回结果如下:
    Reading specs from C:/Perl/dev_cpp/DEV-CPP/Bin/../lib/gcc/mingw32/3.4.2/specs
    Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=
    mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable
    -languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --e
    nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-ja
    va-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchroniz
    ation --enable-libstdcxx-debug
    Thread model: win32
    gcc version 3.4.2 (mingw-special)
9,安装dmake。直接在命令行里面输入:ppm install dmake。安装成功。命令行输入dmake -V。注意是大写的V,返回结果:
    dmake.exe - Version 4.11-20080107-SHAY (Windows / MS Visual C++)
    Copyright (c) 1990,...,1997 by WTI Corp.

    Default Configuration:
            MAXLINELENGTH := 32766
            MAXPROCESSLIMIT := 4
            MAXPROCESS := 1
            .IMPORT .IGNORE: DMAKEROOT
            .MAKEFILES : makefile.mk makefile
            .SOURCE    : .NULL
            DMAKEROOT *= $(ABSMAKECMD:d)startup
            MAKESTARTUP := $(DMAKEROOT)\startup.mk

    Please read the NEWS file for the latest release notes.
10,命令行下进入coro的目录,运行命令:perl makefile.pl
11,命令行下输入:dmake。返回:
    dmake.exe:  Error: -- `C:\Perl\libConfig.pm' not found, and can't be made
    一番搜索之后,有人建议将模块目录中makefile(native下的文件)文件里面的DIRFILESEP = ^\改成DIRFILESEP = \\
    改完之后,再次dmake。又有问题:
    dmake.exe:  Error executing 'rem': No such file or directory
    dmake.exe:  Error code 255, while making 'blibdirs'
    神啊,这是为什么啊?
    又是一番搜索,仿佛找到了蛛丝马迹。命令行下运行:perl -MConfig -e "print $Config{make}"
    结果返回:nmake , 手工删除该nmake.exe文件
    原来这就是问题所在。dev-cpp里面的应该是dmake的,而vc之类的是nmake的。所以赶紧的把perl\bin目录里面的nmake15.exe和nmake.err文件给删了。
    再运行:perl -MConfig -e "print $Config{make}"
    返回:dmake
    终于对了。
12,然后就是重新perl makefile.pl
13,dmake
14,dmake test
15,dmake install
安装成功!

【出处http://hi.baidu.com/qkgztdd

 

g++.exe -c      -nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STR ICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_I MPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T -MD -Zi -DNDEBUG -O1         -DVERS ION=\"\"        -DXS_VERSION=\"\"  "-IC:\Perl\lib\CORE"   Distributions.cxx
g++.exe: unrecognized option `-nologo'
g++.exe: unrecognized option `-GF'
g++.exe: unrecognized option `-Zi'
g++.exe: unrecognized option `-Zi'
cc1plus.exe: error: unrecognized option `-W3'
dmake.exe:  Error code 129, while making 'Distributions.obj'
dmake:  Error code 255, while making 'subdirs'

------------------------------------------------------------------------

Ok I got Inline working.

As Rob suggested I tried to overwrite my Active Perl install because it's configuration was odd, and this fixed some of the problems but now when I ask about Perl C compiler it gives me the full path E:/xampp/perl/site/bin/gcc.exe instead of just 'gcc' and surprisingly when I open Config_heavy.pl file I can't find that anywhere, my Config_heavy says cc:'gcc' so why Perl gives compiler with full path?? I guess Perl is using another file for detecting configurations, I really couldn't find where is that so I had to make some of my usual hacks :P here is what I did maybe this can help someone, but in all this is not a recommended method to get Inline working unless you're really really know what you're doing and you used every method suggested by the Inline list who really know what they are doing unlike me :))

Here is what I did After installing ActivePerl Mingw package

ppm install Mingw

I downloaded strawberry zipped package (Not installer) then unpacked it, make sure to download the same version of your Active Perl version, in my situation it's Perl 5.10

I copied c folder from strawberry and placed it in the same folder where my Perl folder resides

I copied strawberry/perl/lib/Core folder and placed it in my ActivePerl/lib folder, this will ask you to replace the current CORE folder just accept to replace all

Then I opened strawberry/perl/lib/Config_heavy.pl file replaced all C:/strawberry/Perl with my ActivePerl location, in my case it's E:/xampp/Perl then saved Config_heavy and placed it in E:/xampp/Perl/lib, this will ask you to overwrite the current Config_heavy.pl accept that and you're done

Please remember to back up your Perl folder before doing this so if any odd behavior you can delete and place the backup again and try something else, I always do that

Now after trying my Perl with Inline it works just fine plus every other Module and script I wrote previously, so everything seems ok

Thank you guys for being a lot of help, I'll go now and play with the great Inline module
Perl : awesome
C: rules

:))

here is my final Perl -V output

D:\>Perl -V
Summary of my perl5 (revision 5 version 10 subversion 1) configuration:

  Platform:
    osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
    uname='Win32 strawberryperl 5.10.1.3 #1 Thu Jul 29 10:08:11 2010 i386'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE - DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVCRT_RE ADFIX',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='3.4.5', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long long', lseek size=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"E:\xampp\perl\lib\CORE" -L"E:\xampp\c\lib"'
    libpth=E:\xampp\c\lib
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi3
2 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversio
n -lodbc32 -lodbccp32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladv api32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lve
rsion -lodbc32 -lodbccp32
    libc=, so=dll, useshrplib=true, libperl=libperl510.a
    gnulibc_version=''   Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"E:\xampp\perl\lib\CORE"
-L"E:\xampp\c \lib"'

Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
                        PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
                        PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS
                        USE_LARGE_FILES USE_PERLIO USE_SITECUSTOMIZE
  Locally applied patches:
        ActivePerl Build 1007 [291969]
        0abd0d disable non-unicode case insensitive trie matching
  Built under MSWin32
  Compiled at Jan 26 2010 23:15:11
  @INC:
    E:/xampp/perl/site/lib
    E:/xampp/perl/lib


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap