0.说明
在Windows平台编译并调试
OpenJDK7相对比较复杂,感兴趣的读者可以先按照本文的步骤在虚拟机环境下进行,然后再转移到物理机上。
或则,将虚拟机环境下构建好了的Cygwin和
OpenJDK7工程打包到物理机上,然后配置相应的环境变量即可。
本文是在VMware Workstation的Windows 7 Ultimate en x86环境下编译并调试
OpenJDK7u40的32bit版本。
本文所有的编译构建工作都将在C:\BuildJDK目录下完成,读者在具体的编译过程中,可根据实际的物理机情况进行调整。
1.安装DXSDK
安装DXSDK_Jun10.exe,本文将其安装到C:\BuildJDK\MSDXSDK\June2010目录中:
2.安装Visual Studio 2010
根据OpenJDK7u40的编译指南说明,
OpenJDK7
需要使用VS2010提供的编译器,因此本文选择安装en_visual_studio_2010_ultimate_x86_dvd_509116.iso
本文在虚拟环境下选择将en_visual_studio_2010_ultimate_x86_dvd_509116.iso安装到默认的路径:C:\Program Files\Microsoft Visual Studio 10.0
3.安装JDK
根据OpenJDK7u40的编译指南说明,编译
OpenJDK7
需要提供JDK6的Release版本,但由于本文所编译的
OpenJDK7u40版本比较新,因此
也可以选择JDK7的某个Release版本,本文选择
jdk-7u51-windows-i586.exe作为
OpenJDK7u40
的Bootstrap JDK,将JDK7u50安装到C:\BuildJDK\JDK\Java目录中:
4.安装Ant
编译
OpenJDK7
需要Ant 1.7.1或者之后的一个Release版本,本文选择apache-ant-1.9.4-bin.zip,将其解压,并重命名为Ant,移动到
C:\BuildJDK目录中:
5.安装Cygwin
在Windows下编译
OpenJDK7
,需要一款Uninx命令行工具Cygwin,本文选择安装Cygwin-x86.exe,
OpenJDK7u40
的编译指南中要求必须安装如下包:
Binary Name Category Package Description ar.exe Devel binutils The GNU assembler, linker and binary utilities make.exe Devel make The GNU version of the 'make' utility built for CYGWIN.
NOTE: See the GNU make sectionm4.exe Interpreters m4 GNU implementation of the traditional Unix macro processor cpio.exe Utils cpio A program to manage archives of files gawk.exe Utils awk Pattern-directed scanning and processing language file.exe Utils file Determines file type using 'magic' numbers zip.exe Archive zip Package and compress (archive) files unzip.exe Archive unzip Extract compressed files in a ZIP archive free.exe System procps Display amount of free and used memory in the system
但安装中发现还需要其它的包:
libintl3(cygintl-3.dll)
gcc\gdb\grep\sed\find
gcc-c++
libXp
libXp-devel
libXtst
libXtst-devel
libXt
libXt-devel
cups
cups-devel
libXrender
libXrender-devel
libXpm
libXpm-devel
libXi
libXi-devel
alsa-lib
alsa-lib-devel
freetype
freetype-devel
本文将Cygwin安装到C:\BuildJDK\Cygwin\cygwin目录中,将安装过程中的下载文件存放到C:\BuildJDK\Cygwin\Install目录中:
安装过程的几张截图如下:
安装过程中的包,需要自己去查找安装,比如需要安装libintl3这个包,在Search中输入libintl3即可搜索到:
6.编译make
解压
make-3.82.tar.gz文件,重命名为Make,并移动到C:\BuildJDK目录中:
启动一个CMD命令行工具,cd到C:\BuildJDK\Make目录中:
配置Cygwin环境变量: