perlwin32 (1) Linux Manual Page
NAME
perlwin32 – Perl under Windows
SYNOPSIS
These are instructions for building Perl under Windows 2000 and later.
DESCRIPTION
Before you start, you should glance through the README file found in the top-level directory to which the Perl distribution was extracted. Make sure you read and understand the terms under which this software is being distributed.
Also make sure you read “BUGS AND CAVEATS” below for the known limitations of this port.
The INSTALL file in the perl top-level has much information that is only relevant to people building Perl on Unix-like systems. In particular, you can safely ignore any information that talks about “Configure”.
You may also want to look at one other option for building a perl that will work on Windows: the README.cygwin file, which give a different set of rules to build a perl for Windows. This method will probably enable you to build a more Unix-compatible perl, but you will also need to download and use various other build-time and run-time support software described in that file.
This set of instructions is meant to describe a so-called “native” port of Perl to the Windows platform. This includes both 32-bit and 64-bit Windows operating systems. The resulting Perl requires no additional software to run (other than what came with your operating system). Currently, this port is capable of using one of the following compilers on the Intel x86 architecture:
Microsoft Visual C++ version 6.0 or later
Intel C++ Compiler (experimental)
Gcc by mingw.org gcc version 3.4.5 or later
with runtime < 3.21
Gcc by mingw-w64.org gcc version 4.4.3 or later
Note that the last two of these are actually competing projects both delivering complete gcc toolchain for MS Windows:
- <http://mingw.org>
- Delivers gcc toolchain targeting 32-bit Windows platform.
- <http://mingw-w64.org>
- Delivers gcc toolchain targeting both 64-bit Windows and 32-bit Windows platforms (despite the project name “mingw-w64” they are not only 64-bit oriented). They deliver the native gcc compilers and cross-compilers that are also supported by perl’s makefile.
The Microsoft Visual C++ compilers are also now being given away free. They are available as “Visual C++ Toolkit 2003” or “Visual C++ 2005-2019 Express [or Community, from 2017] Edition” (and also as part of the “.NET Framework SDK”) and are the same compilers that ship with “Visual C++ .NET 2003 Professional” or “Visual C++ 2005-2019 Professional” respectively.
This port can also be built on IA64/AMD64 using:
Microsoft Platform SDK Nov 2001 (64-bit compiler and tools)
MinGW64 compiler (gcc version 4.4.3 or later)
The Windows SDK can be downloaded from <http://www.microsoft.com/>. The MinGW64 compiler is available at <http://mingw-w64.org>. The latter is actually a cross-compiler targeting Win64. There’s also a trimmed down compiler (no java, or gfortran) suitable for building perl available at: <http://strawberryperl.com/package/kmx/64_gcctoolchain/>
NOTE: If you’re using a 32-bit compiler to build perl on a 64-bit Windows operating system, then you should set the WIN64 environment variable to “undef”. Also, the trimmed down compiler only passes tests when USE_ITHREADS *= define (as opposed to undef) and when the CFG *= Debug line is commented out.
This port fully supports MakeMaker (the set of modules that is used to build extensions to perl). Therefore, you should be able to build and install most extensions found in the CPAN sites. See “Usage Hints for Perl on Windows” below for general hints about this.
Setting Up Perl on Windows
- Make
- You need a “make” program to build the sources. If you are using Visual C++ or the Windows SDK tools, you can use nmake supplied with Visual C++ or Windows SDK. You may also use, for Visual C++ or Windows SDK, dmake or gmake instead of nmake. dmake is open source software, but is not included with Visual C++ or Windows SDK. Builds using gcc need dmake or gmake. nmake is not supported for gcc builds. Parallel building is only supported with dmake and gmake, not nmake. When using dmake it is recommended to use dmake 4.13 or newer for parallel building. Older dmakes, in parallel mode, have very high CPU usage and pound the disk/filing system with duplicate I/O calls in an aggressive polling loop.
A port of dmake for Windows is available from:
<http://search.cpan.org/dist/dmake/>
Fetch and install dmake somewhere on your path.
- Command Shell
- Use the default “cmd” shell that comes with Windows. Some versions of the popular 4DOS/NT shell have incompatibilities that may cause you trouble. If the build fails under that shell, try building again with the cmd shell.
Make sure the path to the build directory does not contain spaces. The build usually works in this circumstance, but some tests will fail.
- Microsoft Visual C++
- The nmake that comes with Visual C++ will suffice for building. Visual C requires that certain things be set up in the console before Visual C will sucessfully run. To make a console box be able to run the C compiler, you will need to beforehand, run the "vcvars32.bat" file to compile for x86-32 and for x86-64 "vcvarsall.bat x64" or "vcvarsamd64.bat". On a typical install of a Microsoft C compiler product, these batch files will already be in your "PATH" environment variable so you may just type them without an absolute path into your console. If you need to find the absolute path to the batch file, it is usually found somewhere like C:\Program Files\Microsoft Visual Studio\VC98\Bin. With some newer Micrsoft C products (released after ~2004), the installer will put a shortcut in the start menu to launch a new console window with the console already set up for your target architecture (x86-32 or x86-64 or IA64). With the newer compilers, you may also use the older batch files if you choose so.
- Microsoft Visual C++ 2008-2019 Express/Community Edition
- These free versions of Visual C++ 2008-2019 Professional contain the same compilers and linkers that ship with the full versions, and also contain everything necessary to build Perl, rather than requiring a separate download of the Windows SDK like previous versions did.
These packages can be downloaded by searching in the Download Center at <http://www.microsoft.com/downloads/search.aspx?displaylang=en>. (Providing exact links to these packages has proven a pointless task because the links keep on changing so often.)
Install Visual C++ 2008-2019 Express/Community, then setup your environment using, e.g.
C:\Program Files\Microsoft Visual Studio 12.0\Common7\Toolssvars32.bat
(assuming the default installation location was chosen).
Perl should now build using the win32/Makefile. You will need to edit that file to set CCTYPE to one of MSVC90-MSVC142 first.
- Microsoft Visual C++ 2005 Express Edition
- This free version of Visual C++ 2005 Professional contains the same compiler and linker that ship with the full version, but doesn’t contain everything necessary to build Perl.
You will also need to download the “Windows SDK” (the “Core SDK” and “MDAC SDK” components are required) for more header files and libraries.
These packages can both be downloaded by searching in the Download Center at <http://www.microsoft.com/downloads/search.aspx?displaylang=en>. (Providing exact links to these packages has proven a pointless task because the links keep on changing so often.)
Try to obtain the latest version of the Windows SDK. Sometimes these packages contain a particular Windows OS version in their name, but actually work on other OS versions too. For example, the “Windows Server 2003 R2 Platform SDK” also runs on Windows XP SP2 and Windows 2000.
Install Visual C++ 2005 first, then the Platform SDK. Setup your environment as follows (assuming default installation locations were chosen):
SET PlatformSDKDir = C :\Program Files\Microsoft Platform SDK SET PATH = % SystemRoot %\system32; % SystemRoot % ; C :\Program Files\Microsoft Visual Studio 8\Common7\IDE; C :\Program Files\Microsoft Visual Studio 8\VC\BIN; C :\Program Files\Microsoft Visual Studio 8\Common7\Tools; C :\Program Files\Microsoft Visual Studio 8\SDK2 .0in; C :\WINDOWS\Microsoft.NET\Framework2 .0.50727; C :\Program Files\Microsoft Visual Studio 8\VC\VCPackages; % PlatformSDKDir %\Bin SET INCLUDE = C :\Program Files\Microsoft Visual Studio 8\VC\INCLUDE; % PlatformSDKDir %\include SET LIB = C :\Program Files\Microsoft Visual Studio 8\VC\LIB; C :\Program Files\Microsoft Visual Studio 8\SDK2 .0\lib; % PlatformSDKDir %\lib SET LIBPATH = C :\WINDOWS\Microsoft.NET\Framework2 .0.50727(The PlatformSDKDir might need to be set differently depending on which version you are using. Earlier versions installed into “C:\Program Files\Microsoft SDK”, while the latest versions install into version-specific locations such as “C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2”.)
Perl should now build using the win32/Makefile. You will need to edit that file to set
CCTYPE = MSVC80
and to set CCHOME, CCINCDIR and CCLIBDIR as per the environment setup above.
- Microsoft Visual C++ Toolkit 2003
- This free toolkit contains the same compiler and linker that ship with Visual C++ .NET 2003 Professional, but doesn’t contain everything necessary to build Perl.
You will also need to download the “Platform SDK” (the “Core SDK” and “MDAC SDK” components are required) for header files, libraries and rc.exe, and “.NET Framework SDK” for more libraries and nmake.exe. Note that the latter (which also includes the free compiler and linker) requires the “.NET Framework Redistributable” to be installed first. This can be downloaded and installed separately, but is included in the “Visual C++ Toolkit 2003” anyway.
These packages can all be downloaded by searching in the Download Center at <http://www.microsoft.com/downloads/search.aspx?displaylang=en>. (Providing exact links to these packages has proven a pointless task because the links keep on changing so often.)
Try to obtain the latest version of the Windows SDK. Sometimes these packages contain a particular Windows OS version in their name, but actually work on other OS versions too. For example, the “Windows Server 2003 R2 Platform SDK” also runs on Windows XP SP2 and Windows 2000.
Install the Toolkit first, then the Platform SDK, then the .NET Framework SDK. Setup your environment as follows (assuming default installation locations were chosen):
SET PlatformSDKDir = C :\Program Files\Microsoft Platform SDK
SET PATH = % SystemRoot %\system32;
% SystemRoot % ;
C :\Program Files\Microsoft Visual C++ Toolkit 2003in;
% PlatformSDKDir %\Bin;
C :\Program Files\Microsoft.NET\SDK1 .1\Bin
SET INCLUDE = C :\Program Files\Microsoft Visual C++ Toolkit 2003\include;
% PlatformSDKDir %\include;
C :\Program Files\Microsoft Visual Studio.NET 2003\Vc7\include
SET LIB = C :\Program Files\Microsoft Visual C++ Toolkit 2003\lib;
% PlatformSDKDir %\lib;
C :\Program Files\Microsoft Visual Studio.NET 2003\Vc7\lib(The PlatformSDKDir might need to be set differently depending on which version you are using. Earlier versions installed into “C:\Program Files\Microsoft SDK”, while the latest versions install into version-specific locations such as “C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2”.)
Several required files will still be missing:
-
- •
- cvtres.exe is required by link.exe when using a .res file. It is actually installed by the .NET Framework SDK, but into a location such as the following:
C:\WINDOWS\Microsoft.NET\Framework1.1.4322
Copy it from there to %PlatformSDKDir%\Bin
- •
- lib.exe is normally used to build libraries, but link.exe with the /lib option also works, so change win32/config.vc to use it instead:
Change the line reading:
ar='lib'to:
ar='link /lib'It may also be useful to create a batch file called lib.bat in C:\Program Files\Microsoft Visual C++ Toolkit 2003in containing:
@echo off link /lib %*for the benefit of any naughty C extension modules that you might want to build later which explicitly reference “lib” rather than taking their value from $Config{ar}.
- •
- setargv.obj is required to build perlglob.exe (and perl.exe if the USE_SETARGV option is enabled). The Platform SDK supplies this object file in source form in %PlatformSDKDir%\src
