OpenJDK Cookbook
上QQ阅读APP看书,第一时间看更新

Installing Cygwin for Windows builds

Like most of the other cross-platform open source projects, OpenJDK uses Unix-like tools for the build process. Tools such as gmake, awk, and cpio are ubiquitous for the Unix and Linux world and may be found on almost any Unix-like platform. However, these tools are based on Unix process behavior, and that becomes a problem when we want to run them on Windows.

Cygwin is a set of free and open source tools being developed by Red Had, Inc. and provides limited support for the Unix-like environment in Windows. It is required to build OpenJDK on Windows.

OpenJDK requires Cygwin i586 for both i586 and amd64 builds. The installation procedure is the same for both Windows 7 SP1 i586 and Windows 7 SP1 amd64 so we won't mention architecture further in this recipe.

Getting ready

To install and successfully use Cygwin, we'll need a clean installation of Windows 7 SP1 without antivirus software running.

How to do it...

The following steps will help us to install Cygwin:

  1. Download setup-x86.exe from the http://cygwin.com/ website.
  2. Run the installer and choose http://mirrors.kernel.org as a packages' mirror.
  3. Choose the additional packages:
    Devel/binutils
    Interpreters/m4
    Utils/cpio
    Archive/zip
    Archive/unzip
    System/procps
  4. Perform the installation into the directory with the path in ASCII letters or numbers without spaces.

How it works...

Any antivirus software (or similar software that may scan the memory of other applications) is prohibited because it may interfere with Cygwin. Cygwin uses complex techniques to simulate the fork functionality of Unix on Windows. These techniques may not work with antivirus scanners running.

Only the i586 version on Cygwin is supported to build OpenJDK. The amd64 Cygwin may or may not work.

The Cygwin community hosts a lot of packages' mirrors worldwide. We use the https://www.kernel.org/ mirror as one that should have the most complete set of prebuilt packages:

  • The binutils package is required for the ar utility. This is a special kind of archiver that may be used to create and update static libraries
  • The m4 package is required to work with classic Unix macro processor scripts
  • The cpio utility is used as an archiver because it may be much faster than the more popular tar utility in some environments
  • The procps package is required for the free utility, which is used to get information about free and used memory

There's more...

OpenJDK 6 can also be built using commercial MKS toolkit. This method provides shorter build times, but is not supported for OpenJDK 8 and above.

A Cygwin installation may be copied from one Windows box to another without installation. This may be useful for builds on clean Windows boxes. Besides the usual windows binaries, Cygwin uses special kinds of symlink files, for example, bin/awk actually points to bin/gawk.exe. These symlinks may be crippled if loaded into or from version control systems such as Git. This problem may be circumvented by replacing symlinks with copies of actual binaries with symlink names: gawk.exe to awk.exe and so on.

See also