手動編譯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 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