Informatics

Perl CPAN on Windows 7 64 bit

What if you want to install Perl packages that are not included in the precompiled repositories for ActiveState Perl on your Windows 7 64 bit?

If packages are included in the default ActiveState Perl repository, then there’s no problem: you can just use “ppm” from the command line.
In previous versions of ActiveState Perl, ppm was like a preconfigured cpan, but now it opens a GUI where you can easily search and install packages.

If you need a CPAN package that hasn’t been included by default, you can try to add a proper repository that includes the desired package.
You can find some of them here.

If any of this lead to success, you can use CPAN from the command line.
But cpan will not see any C compiler, nor “make” available:


    C:\>cpan

    It looks like you don't have a C compiler and make utility installed. Trying
    to install dmake and the MinGW gcc compiler using the Perl Package Manager.
    This may take a a few minutes...

    ppm.bat install failed: Can't find any package that provides MinGW

    It looks like the installation of dmake and MinGW has failed. You will not be
    able to run Makefile commands or compile C extension code. Please check your
    internet connection and your proxy settings!

    cpan shell -- CPAN exploration and modules installation (v1.960001)
    Enter 'h' for help.

In 64 bits I think that you can only use the Visual C++ compiler included in the Windows SDK 7.1 1: they’re provided free of charge.
Windows SDK 7.1 1 can be downloaded here:

The package requires the previous installation of the .NET Framework version 4, or it will not install de compilers, which is the key option that we’re looking for.
Note that it is not enough the .Net Client Framework.
So first install the .NET Framework version 4 from here:

http://www.microsoft.com/en-us/download/details.aspx?id=17851

Now, install Windows SDK 7.1, and be sure to select the option “Compilers” during the process.

After that, you’ll have to start cpan from a preconfigured command line window:
Open ms-dos, and type (verify that this is the correct path for you):

    "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.Cmd" /x64 /release

After this, the msdos characters change to yellow to signal that some environment variables have been set (LIB, PATH, INCLUDE).
Now you can safely type cpan, and install your favourite Perl CPAN package.
If everything runs well, it will compile.

Sometimes “make” is successful, but some tests fail…
If you know what you are doing (the test can fail for some architecture issue or something that you know is safe for your future apps), you can force the installation with “force”:

    force install PACKAGE
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s