全部博文(413)
分类: WINDOWS
2007-07-18 17:09:14
Welcome to the Monastery | |
A guide to installing modules for Win32by |
PerlMonks Discussion |
on Feb 26, 2005 at 20:15 UTC ( #=perltutorial: , ) |
This article is meant as an extension to 's well written . But this one focuses on the peculiarites of installation on Windows machines.
Installing modules directly from is easy, as long as the module contains no XS-extensions (C-code). Most Windows installations don't have a C-compiler, and even if there is one, the compilation of the XS-extensions is a tricky thingy, that can easily fail. So what can you do if you can't compile? The answer is: use a precompiled version. The probably most popular port of Perl for Win32 is from . It ships with a tool named ppm, aka the Programmer's Package Manager. ppm is a tool for installing modules, similar to the CPAN-shell. With it you can download and install modules, with or without XS-Extensions, with a few keystrokes. The following describes the ppm Version that comes with Perl 5.8.0 and above. It differs slightly from the pppm that came with Perl 5.6 Sidenote: Advantages and features of ppm
As always, there are some tripwires and things you should know. Disadvantages
To invoke ppm, simply type ppm at the Windows console ("DOS") command line. The result will look similar to this: C:\>ppm To get immediate help in the ppm-shell, type help or help
In order to install a module you have basically two possibilities.
Direct install To install a module (here: Death::Star) directly, simply type ppm> install Death::Star There is a drawback to using this method. If ppm finds more than one version of a module, you cannot choose which one gets installed. Naturally the most recent version gets installed, but there may be a case when you need to install another version. E.g. the most recent version can be buggy, or incompatible with another module you use. You don't neccessarily need to use the ppm-shell to install a module. You can also use the following command to install a module directly from the command line. C:\> ppm install Death::Star Search-and-Install To search for a module you use the search ppm> search Death::Star You can find out more about a module by using the desc ppm> desc 2 To install a module from the list, type install, followed by the module's number. ppm> install 2 Regardless which method you choose, ppm will start to install the module and produce output like this: Package 2: If the module has dependencies (that is, it requires another module to work correctly) the dependencies are installed first. From above, you may have noticed the term Active Repositories. ppm downloads the modules from special websites that are called repositories. A repository is a just a directory or a script that serves a list of ppd files to ppm. From these ppd files, ppm gets the actual location of the module's tarball. A freshly installed ActivePerl will come with two repositories. To find out about them, type rep. ppm> rep In order to find out, which url a repository points to, you can use the rep desc ppm> rep desc 1 A lot of modules are not available from the standard repositories. Thank crunchy, the community provides a lot of alternative repositories that offer the missing modules. For example our fellow brother hosts a repository at . If you want to add such a repository to ppm you will have to use the rep add ppm> rep add jenda From there on, the repository is known to ppm and will be used for future searches. You don't need to permanently add a repository to install a module from it. You can specify the repository from the command line. C:\> ppm install So how, you might ask, do I find out where these repositories are? The answer to this question is PPM::Repositories.pm. That's a module that basically consists of a list of all known repositories. The, at the time of this writing, most recent version (0.9) is available at bribe's repository at With the following script, you can use PPM::Repositories.pm to add all known repositories to your ppm.use PPM::Repositories; You should be aware that the more repositories you add, the longer it takes for a search to finish. If you are behind a proxy, you will notice that ppm cannot connect to the internet. To make it work, you will have to set a bunch of environment-variables, where xxx.xxx.xxx.x is the ip-address of the proxy, and y the port: c:\> set http_proxy= Instead of entering the variables each time you before you start ppm, you have other possibilities to set them:
Still there may be some environments where that fails. But don't worry, there is an alternative, namely creating a local repository. The first step doing so is to create a directory on your system that serves as the repository. Name and position of that directory is not important, I use /perl/ppm/repository as an example. Then add that directory to your ppm using the command described in ppm> rep add myRepository /perl/ppm/repositoryThe next step is to download the ppd file of the module and save it to your repository. A ppd file is a xml file that contains information about the module's position, version, etc. It looks like
Identify the line that says Now you can use ppm to install the module from your local repository. You also have the choice to install the module manually. To do so, simply download the tarball and extract it with WinZip or a similar program. A typical ppm-distribution looks like this:
C:/blib/ Now you can copy the files manually into your Perl's library tree, namely C:\> copy \blib\lib\Death\Star.pm \Perl\site\lib\Death\Star.pm Be aware that the module's html-documentation will not be integrated into the ActiveState-docs automatically. But if you do a complete rebuild of the HTML documentation, it will be added: perl -MActivePerl::DocTools -e "UpdateHTML(1)" Update: Corrected error concerning "Getting around the proxy" Update: Included 's in the text, as suggested by . holli, /regexed monk/
|
|