Charles Engelke's Blog

April 25, 2004

Building Perl

Filed under: MSVC — Charles Engelke @ 9:25 pm

In an earlier
, I talked about Microsoft’s
Visual C++ Toolkit
. I built Perl
for Windows with it successfully,
but it took me about half a dozen tries. On a Unix machine the
build process is very sophisticated. You run a Configure program,
which figures out everything the build process needs to know about
your environment, then you use make to perform the
actual build. But Configure is a Unix shell script, and you can’t
run it under Windows.

The Perl team has done 99% of what Configure would otherwise do for
us Windows users, providing us a Makefile that’s almost ready to
use. You need to edit a few things in the Makefile, which isn’t
too tough. You also have to have your development tools set up
properly, and avoid a few Windows “gotchas”. Here’s what I did that
finally worked (after about five tries).

  1. Unpack the stable tarball with WinZip or Cygwin’s tar. (The tar command
    is tar xzvf stable.tar.gz.) Change to the
    win32 folder in the unpacked directory tree. Warning:
    unpack this in a folder with no spaces in its name! Otherwise,
    most of the build works, but the test fails. Apparently, something
    in the build files doesn’t expect spaces in file paths.
  2. Edit the Makefile, performing the following changes:
    • Change INST_TOP = $(INST_DRV)\perl to
      indicate where you want Perl to end up. Since I was just
      experimenting, I changed it to INST_TOP = c:\myperl.
    • Comment out the line CCTYPE = MSVC60 by
      putting a # at the front (or just delete it). The free
      toolkit is different enough that we don’t want the build
      process to perform any special steps for Visual C++ 6.0.
    • Replace CCHOME = $(MSVCDIR) with the location
      of your C++ Toolkit. For the default installation, that
      gives CCHOME = C:\Program Files\Microsoft Visual C++
      Toolkit 2003
    • There are a couple of lines that set compiler flags. They
      each contain -nologo -Gf -W3. Change the
      -Gf to -GF, to keep the
      compiler from warning you that the option is deprecated
      and will stop working in some future version.
    • There’s a line containing perlglob$(o) setargv$(o).
      Delete setargv$(o). I don’t know why; I
      saw this as a hint, and it fixed an error I was getting, and
      my build still passed all tests.
  3. In the win32 folder of the unpacked distribution,
    type the command nmake. After that’s done, without
    errors (it worked for me), type nmake test. If
    that goes okay, type nmake install.

That’s it! You’ve built Perl from source (and now you can install
even binary modules from CPAN).


Blog at

%d bloggers like this: