I've been doing quite a bit of Perl scripting for Yahoo! Hacks, and I can safely say it's my scripting language of choice now. A big reason for this is the abundance of pre-existing modules available. Why reinvent the wheel if someone else has been there before? I also develop most of the scripts on a Windows machine running ActivePerl
. It works well, but the modules available via the ActiveState Perl Package Manager
leave something to be desired. Many of the modules I want to use are only available via CPAN
, which means I have to compile the modules for Windows myself.
Compiling Perl modules isn't normally a big deal. In fact, on my Mac it's a snap. I simply downloaded the Mac Developer Tools
and started make
-ing stuff all day long. I assume the same is true for Linux. Windows is another story.
Compiling modules would probably be easy if I was a C++ developer, and had a copy of Visual Studio Something-or-other with its own compiler. But I'm a thrifty scripter, and I just want some Perl modules to work. So I had to go through a series of steps, and put all of the pieces into place to be able to compile modules. I thought I'd write it up here in case anyone else out there is pulling their hair out like I was.
How to compile Perl modules on Windows without a Visual Studio:
- Get nmake. (direct link to file.) This is your compiler.
- Sometimes you'll need a file called Windows.h. Install the Windows SDK.
- Sometimes you'll need a file called msvcrt.lib or msvcr70.lib. Install the .NET framework SDK.
- For everything else you need install the Visual C++ Toolkit.
- At this point, you will have installation fatigue. Take a break.
- Inside the VC++ Toolkit is an important file called vcvars32.bat that adds some key directories to your system
PATH variable. Edit this file so that the lib and bin directories of each of the kits you just installed will be added to
PATH when you run this batch file.
With these behemoth kits in place, you should be set to start compiling Perl packages. Once in a while you may need the odd odbc32.lib
—it's included with the SQL Server developer tools. Don't have it? Start installing. ;) And when you're done, don't forget to add its directory to your
before you start compiling a module to get your paths in order, and then run nmake
like you would make
I was almost in tears when things were compiling correctly. :) I have to let you know that I'm not a Perl expert, and compiling modules like this may wreak havoc with your system. But it's working fine for me.