Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Installing CPAN on a Windows system

by GrandFather (Cardinal)
on Nov 12, 2006 at 20:10 UTC ( #583586=perltutorial: print w/ replies, xml ) Need Help??

Assuming you have installed ActiveState Perl the following is a guide to getting CPAN's cpan module install tool working on a Windows XP system with Visual Studio.

Install Visual Studio1

First up, CPAN gripes endlessley if you try to run nmake from a path including a space. If you have Visual Studio installed to its default location in .../Program Files/... and you are using NTFS then your best bet is to use System Internals' Junction to create a hard link to the Visual Studio install folder (an alternative is to map a path to a virtual drive using the Windows-native command subst - thanks to Roy Johnson for this tip). You can pick Junction up from http://www.sysinternals.com/Utilities/Junction.html. Run it as:

junction c:/vs2003 "C:\Program Files\Microsoft Visual Studio 7"

If you are yet to install Visual Studio then you should seriously consider installing it to a non-default path that doesn't include spaces in the path.

Install cygwin

Install cygwin from http://cygwin.com/setup.exe. When the setup promts you to choose a download site you should choose four or so mirrors to help avoid stale mirror syndrome.

During the install you should add the following non-default packages:

  • Archive/unzip
  • web/lynx
  • web/wget
  • net/ncftp
  • utils/gnupg

Note that you can use the View button to toggle between different package views. "Not Installed" and "Category" are most usefull for this job. Click on "Skip" to select a package for installation.

Installing CPAN

Open a command window using "Programs|Microsoft Visual Studio 200x|Visual Studio Tools|Visual Studio 200x Command Prompt"2

Append the cygwin bin folder to the search path:

set path=%path%;c:\cygwin\bin

Run CPAN - just type cpan on the command line and hit enter. The AS Perl install proivides a batch file on the path that runs the cpan tool.

The first time cpan is run it wants to go through a configuration process. Mostly using the default options is fine. I'd recommend using "follow" at the "Policy on building prerequisites" prompt however.

The most important thing to check is that the path for nmake is correct and doesn't include spaces. If you have a default VS install then most likely you will need to change the path to use the hard link you created with Junction.

Other than that, just accept the defaults and you are done.

TIMTOWTDI

During the first airing of this as a meditation a couple of 'see also's were suggested:

1Oh, there is a gotcha - things go rather pear shaped if you use VS 2005 to build against AS Perl 5.8.7 (815) and earlier builds (and possibly against 5.8.8 when it's available) because the binaries generated by VS 2005 do not play with the VC++ 6 binaries built with an earlier compiler.

2If you use the command line reguarly it is well worth migrating the contents of the batch file invoked by this command into your environment. demerphq has written a script to ease the process - see the update to this node


DWIM is Perl's answer to Gödel

Comment on Installing CPAN on a Windows system
Select or Download Code
Re: Installing CPAN on a Windows system
by syphilis (Canon) on Nov 13, 2006 at 07:23 UTC
    Is it really necessary to install Cygwin ? That's an 'orrible step to have to take. Strawberry Perl manages to include CPAN (but no Cygwin), and I expect the same should be achievable with ActivePerl. Mind you, I don't use the CPAN module, so I can't speak with any authority re how to get it working. (I still download, extract, and manually run that lovely old mantra.)

    I would also never advise anyone to use the free versions of the Microsoft Compilers with ActiveState perl for 2 reasons:

    1) It requires multiple downloads from obscure and ever-changing locations;
    2) It uses a different C runtime to ActivePerl - eg you'll never successfully build Win32::SharedFileOpen using the free MS compiler with ActivePerl because of that runtime discrepancy. (That is, however, the only example I have where the difference in runtime library is a problem.)

    Instead, with ActivePerl, my advice would be to use the MinGW compiler (http://www.mingw.org/download.shtml), which does use the same C runtime, and dmake (http://search.cpan.org/dist/dmake/) - given that ActivePerl now (as of build 815, I think) works seamlessly with that compiler and make utility.

    For older versions of ActivePerl one can still use the MinGW compiler and dmake seamlessly by first also installing ExtUtils::FakeConfig and then setting the environment variable perl5opt to -MConfig_m . Doing so gives excellent milage, and is my preferred modus operandii when using the MinGW compiler with ActivePerl.

    Two things deter me from giving Strawberry Perl my whole hearted support:

    1) It doesn't have a ppm utility;
    2) The MinGW compiler they package doesn't include the g77 fortran compiler;

    Both of those issues are fairly easily addressed - and when they are addressed (which will hopefully happen) it will see the end of long-winded rants like this from me. I'll simply be able to recommend Strawberry Perl and leave it at that.

    I have one other observation regarding the StrawberryPerl v ActivePerl consideration:

    If ActiveState were to decide to (optionally) include MinGW (including g77) and dmake, along with the CPAN bundle, then they would surpass the offering that Strawberry Perl currently provides. That's why I think it's important that Strawberry Perl offers a PPM utility, and includes the g77 fortran compiler. Then, if ActiveState does provide the option I've just mentioned, Strawberry Perl will at least be on an equal footing. And, of course, if ActiveState don't offer the option, then Strawberry Perl is clearly in the lead.

    Anyway, ++ to you GrandFather for what you provided here :-)

    Cheers,
    Rob

      Cygwin is, I believe, just for the tools GrandFather notes in the post. I use CPAN.pm on a system w/just the freebie NMAKE for "pure-Perl" modules, and CPAN.pm uses the Perl modules to take the place of those command-line tools with little problem.

      ----Asim, known to some as Woodrow.

      Perl::Dist::Strawberry -- branches/patches welcome. For repository access, email Adam Kennedy (adamk at cpan dot org).

      g77 is coming soon. Suggestions on the right way to provide free, unencumbered PPM support would be welcome -- just post a page about it at win32.perl.org.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        Good to see that g77 is on the way. As regards PPM, the latest version on CPAN (2.1.8 - though it still reports itself as being 2.1.6) works fine on Strawberry Perl. I can't see that it's encumbered in any way - but I've asked whether there are any licensing issues on ActiveState's PPM mailing list, just in case I missed something.

        It should just be a matter of building it and including it with the Strawberry distro (same as any other non-core module that is pre-built and included with the Strawberry distro). One thing I'm not sure about is the file ppm.bat, which is created (by running pl2bat.bat) during the building of the PPM module. Maybe it can't simply be included as a hardcoded file in the Strawberry distro - perhaps it needs to be created by running pl2bat.bat on the target machine during the Strawberry installation process. I've asked about that aspect, too, on the PPM mailing list. When I've got the answer (to both my queries) I'll post a page on http://win32.perl.org/ as suggested.

        Cheers,

        Rob
      From the mouth of an ActiveState staff member.

      They are legally unable to bundle gcc, because the license clashes with some of the code in ActiveState.
Re: Installing CPAN on a Windows system
by Anonymous Monk on Nov 13, 2006 at 07:39 UTC
Re: Installing CPAN on a Windows system
by xdg (Monsignor) on Nov 13, 2006 at 15:52 UTC
    Installing CPAN on a Windows system
    Assuming you have installed ActiveState Perl

    Windows != ActiveState

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://583586]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-08-29 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (286 votes), past polls