rzer10 has asked for the wisdom of the Perl Monks concerning the following question:

I'm running Active State's Perl 5.8 on my PC. Works great. Love the PPM. It's super easy to install CPAN compiled modules. But what on Earth do you do when there isn't a pre-compiled binary? Specifically, I've written some custom Perl modules with a C++ underbelly using XS. I can compile and run these modules on UNIX (Solaris) using gcc. So how do I compile and run them in Windows? OK, I know that nmake is part of the answer but I do not know if it is the complete answer. It is my understanding that nmake works great if the module install is a glorified copy-to-bin operation but how does it work for heavy compiling? To be honest, nmake looks a little too skinny to be a heavy lifter like gcc. What else do I need to compile modules on Windows?

Replies are listed 'Best First'.
Re: Compiling Perl Modules on Windows
by shigetsu (Hermit) on Apr 30, 2007 at 23:17 UTC
Re: Compiling Perl Modules on Windows
by syphilis (Archbishop) on May 01, 2007 at 00:12 UTC
    To be honest, nmake looks a little too skinny to be a heavy lifter like gcc

    'nmake' is just a make utility (a windows equivalent of 'make'), not a compiler. In addition to using MSVC++, you can also build your modules on ActiveState perl using 'dmake' and (the MinGW port of) gcc/g++ - both of which are freely available.

    Cheers,
    Rob
Re: Compiling Perl Modules on Windows
by jbert (Priest) on May 01, 2007 at 08:59 UTC
    An alternative to activestate is strawberry perl, which has the explicit goal of bundling all you need to build such modules on Windows (gcc, make, etc).

    It's still alpha software, although I'd say that it worked pretty well for me.

Re: Compiling Perl Modules on Windows
by Muggins (Pilgrim) on May 01, 2007 at 09:49 UTC

    I haven't tried Strawberry Perl, but with Activestate's Perl I've had much more success with the MinGW compiler than with MSVC++ (using nmake with both).

    With some versions of ActivePerl you have to also install ExtUtils::FakeConfig and modify the values in that module, specifying whether you're using "nmake" or "dmake", for example, and which compiler you're using. I also had to take out a line trying to link to 'libperl56.a'

    Sometimes ActivePerl seems to spot that you've got MinGW on board and adjust things accordingly, so you don't have to do all this. "perl -V:cc" should tell you "gcc/MinGW" if so.

      Sometimes ActivePerl seems to spot that you've got MinGW on board and adjust things accordingly

      I think that, starting with build 815, it should "spot that you've got MinGW on board". For earlier builds (including the 5.6 builds) you'll need ExtUtils::FakeConfig - which actually provides better milage than the automatic procedure that kicks in with build 815 and later.

      There's a few bugs in the set up that ActiveState provide (but EU::FC seems to get everything right). For builds 815-819 I think you'll find that 'perl -V:ld' tells you 'ld' is set to 'gcc', whereas it should be set to 'g++'. (It only makes a difference when an attempt is made to compile C++ code.) And, for some reason they left 'lib_ext' set to '.lib' - which can also pose problems. With build 820, they've pretty much got everything right - one exception is that 'perl -V:obj_ext' reports '.obj' instead of the correct '.o'. (To fix, comment out the line obj_ext => '.obj', in Perl/site/lib/Config.pm'.)

      Cheers,
      Rob
Re: Compiling Perl Modules on Windows
by rahed (Scribe) on May 01, 2007 at 13:29 UTC
    A viable alternative is to install:
    1. MinGW from http://www.mingw.org/download.shtml
    2. dmake from http://search.cpan.org/~shay/dmake-4.8-20070327-SHAY/
    3. Perl distribution from http://search.cpan.org/~nwclark/perl-5.8.8/

    A good description for the Perl installation on windows is here: http://search.cpan.org/~nwclark/perl-5.8.8/README.win32.

    This way you can use all modules from cpan (of course excluding those requiring the characteristics not present on windows os).
      A viable alternative is to install:
      1. MinGW from http://www.mingw.org/download.shtml


      I think the MinGW folk recommend going instead to sourceforge and downloading then running that installer. There have been reports of problems with the installers on the MinGW page - and I gather that mingw.org site is no longer being actively maintained. The version of the installer on sourceforge is 5.0.3, whereas the latest available version on the mingw.org website is 5.0.2.

      I'm not entirely sure that I'm correct on all points ... but I think that's the current state of play.

      Cheers,
      Rob
        You may be right, it'll be a year I did this install.
        Thanks for adding a sourceforge link.
Re: Compiling Perl Modules on Windows
by rzer10 (Acolyte) on May 03, 2007 at 17:43 UTC
    Thanks to all. There are some excellent options I am exploring.