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环境变量:
set PATH=C:\BuildJDK\Cygwin\cygwin\bin;%PATH%
启动bash
并编译
make-3.82:
bash
./configure
make
开始执行./configure:
./configure执行完毕:
开始执行make:
执行make完毕:
make成功后,会在
C:\BuildJDK\Make中生成make.exe文件:
7.编译FreeType
Cygwin中提供的Freetype版本比较低,因此需要较高版本的Freetype,本文选择用VS2010编译freetype-2.5.0.1.tar.gz,编译步骤如下:
解压freetype-2.5.0.1.tar.gz到
C:\BuildJDK文件夹,并重命名为
FreeType:
用VS2010打开
C:\BuildJDK\FreeType\builds\win32\vc2010目录下FreeType的工程文件freetype.sln
:
编译生成lib文件,配置如下:
•Configuration -> Release Multithreaded
•Platform -> win32
•Target Name -> rename to "freetype"
•Platform Toolset -> v100
配置完成后Build生成freetype.lib:
更改配置生成dll:
配置完成后Build(不是Rebuild)生成freetype.dll:
编译完成后,会在C:\BuildJDK\FreeType\objs\win32\vc2010目录中生成freetype.lib和freetype.dll文件:
8.解压OpenJDK
解压openjdk-7u40-fcs-src-b43-26_aug_2013.zip文件,重命名为OpenJDK,并移动到C:\BuildJDK目录中:
9.配置Drops文件:JAXP和JAX_WS
在C:\BuildJDK\OpenJDK目录下新建
drops目录,将下面四个文件拷贝到
C:\BuildJDK\OpenJDK\drops目录中:
•jaxp-1_4_5-unittests.zip
•jaxp145_01.zip
•jdk7-jaxws2_2_4-b03-2011_05_27.zip
•jdk7-jaf-2010_08_19.zip
10.配置msvcr100.dll文件
将C:\Program Files\Microsoft Visual Studio 10.0\VC\redist\x86\Microsoft.VC100.CRT目录拷贝一份到
C:\BuildJDK目录中,并重命名为
MSVCR100:
11.配置环境变量
打开一个CMD命令行窗口,cd到C:\BuildJDK\OpenJDK目录中:
执行
"C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat",设置环境变量:
执行set > C:/env.txt命令,将当前CMD中的环境变量信息导出到
C:\env.txt文件中:
打开
C:\env.txt文件,仅仅保留其中的PATH、INCLUDE、LIB、
LIBPATH、WindowsSdkDir
,其余信息全部删除:
设置Path环境变量:
在上述env.txt文件中,在INCLUDE、LIB、LIBPATH、Path、WindowsSdkDir
变量前面添加SET命令:
在上述env.txt文件中的末尾增加如下信息,将make、msvcr100.dll、ant、Cygwin、Java添加到Path变量中(
C:\BuildJDK\Make目录一定要放到Cygwin目录前面
):
SET PATH=C:\BuildJDK\Make;%PATH%;C:\BuildJDK\MSVCR100;C:\BuildJDK\Ant\bin;C:\BuildJDK\Cygwin\cygwin\bin;C:\BuildJDK\JDK\Java\jdk1.7.0_51\bin
SET PATH=C:\BuildJDK\Make;%PATH%;C:\BuildJDK\MSVCR100;C:\BuildJDK\Ant\bin;C:\BuildJDK\Cygwin\cygwin\bin;C:\BuildJDK\JDK\Java\jdk1.7.0_51\bin
在上述
env.txt
文件末尾添加如下信息,将编译
OpenJDK7
所需要的头文件添加到INCLUDE变量中:
SET INCLUDE=%INCLUDE%C:\BuildJDK\MSDXSDK\June2010\Include;C:\BuildJDK\Cygwin\cygwin\usr\include;C:\BuildJDK\FreeType\include;C:\BuildJDK\FreeType\include\freetype;
SET INCLUDE=%INCLUDE%C:\BuildJDK\MSDXSDK\June2010\Include;C:\BuildJDK\Cygwin\cygwin\usr\include;C:\BuildJDK\FreeType\include;C:\BuildJDK\FreeType\include\freetype;
在
上述env.txt文件中的末尾增加如下信息,将编译
OpenJDK7
所需要的lib文件添加到LIB、LIBPATH环境变量中:
SET LIB=%LIB%C:\BuildJDK\Ant\lib;C:\BuildJDK\FreeType\objs\win32\vc2010;C:\BuildJDK\JDK\Java\jdk1.7.0_51\lib;C:\BuildJDK\MSDXSDK\June2010\Lib\x86;
SET LIBPATH=%LIBPATH%C:\BuildJDK\Ant\lib;C:\BuildJDK\FreeType\objs\win32\vc2010;C:\BuildJDK\JDK\Java\jdk1.7.0_51\lib;C:\BuildJDK\MSDXSDK\June2010\Lib\x86;
SET LIB=%LIB%C:\BuildJDK\Ant\lib;C:\BuildJDK\FreeType\objs\win32\vc2010;C:\BuildJDK\JDK\Java\jdk1.7.0_51\lib;C:\BuildJDK\MSDXSDK\June2010\Lib\x86;
SET LIBPATH=%LIBPATH%C:\BuildJDK\Ant\lib;C:\BuildJDK\FreeType\objs\win32\vc2010;C:\BuildJDK\JDK\Java\jdk1.7.0_51\lib;C:\BuildJDK\MSDXSDK\June2010\Lib\x86;
<span style="font-family:Microsoft YaHei UI;"></span><img src="http://img.blog.csdn.net/20140526204357593?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQkRYX0hhZG9vcF9PcHQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />
在
上述env.txt文件中的末尾增加如下信息,添加编译
OpenJDK7
所需要的其它环境变量:
SET ALT_DXSDK_PATH=C:\BuildJDK\MSDXSDK\June2010
SET ALT_COMPILER_PATH=C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
SET ALT_BOOTDIR=C:\BuildJDK\JDK\Java\jdk1.7.0_51
SET ALT_JDK_IMPORT_PATH=C:\BuildJDK\JDK\Java\jdk1.7.0_51
SET ALT_CYGWIN_PATH=C:\BuildJDK\Cygwin\cygwin
SET ALT_FREETYPE_LIB_PATH=C:\BuildJDK\FreeType\objs\win32\vc2010
SET ALT_FREETYPE_HEADERS_PATH=C:\BuildJDK\FreeType\include
SET ALT_DROPS_DIR=C:\BuildJDK\OpenJDK\drops
SET ALT_MSVCRNN_DLL_PATH=C:\BuildJDK\MSVCR100
SET ZIP_DEBUGINFO_FILES=0
SET FULL_DEBUG_SYMBOLS=1
SET HOTSPOT_BUILD_JOBS=2
SET PARALLEL_COMPILE_JOBS=2
SET ALLOW_DOWNLOADS=true
SET DEBUG_NAME=debug
SET BUILD_CORBA=false
SET LANG=C
SET ALT_DXSDK_PATH=C:\BuildJDK\MSDXSDK\June2010
SET ALT_COMPILER_PATH=C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
SET ALT_BOOTDIR=C:\BuildJDK\JDK\Java\jdk1.7.0_51
SET ALT_JDK_IMPORT_PATH=C:\BuildJDK\JDK\Java\jdk1.7.0_51
SET ALT_CYGWIN_PATH=C:\BuildJDK\Cygwin\cygwin
SET ALT_FREETYPE_LIB_PATH=C:\BuildJDK\FreeType\objs\win32\vc2010
SET ALT_FREETYPE_HEADERS_PATH=C:\BuildJDK\FreeType\include
SET ALT_DROPS_DIR=C:\BuildJDK\OpenJDK\drops
SET ALT_MSVCRNN_DLL_PATH=C:\BuildJDK\MSVCR100
SET ZIP_DEBUGINFO_FILES=0
SET FULL_DEBUG_SYMBOLS=1
SET HOTSPOT_BUILD_JOBS=2
SET PARALLEL_COMPILE_JOBS=2
SET ALLOW_DOWNLOADS=true
SET DEBUG_NAME=debug
SET BUILD_CORBA=false
SET LANG=C
将
上述env.txt文件中的所有斜杠"\"全部替换为反斜杠"/":
替换完成后,
上述env.txt文件中所有内容如下:
SET INCLUDE=C:/Program Files/Microsoft Visual Studio 10.0/VC/INCLUDE;C:/Program Files/Microsoft Visual Studio 10.0/VC/ATLMFC/INCLUDE;C:/Program Files/Microsoft SDKs/Windows/v7.0A/include;
SET LIB=C:/Program Files/Microsoft Visual Studio 10.0/VC/LIB;C:/Program Files/Microsoft Visual Studio 10.0/VC/ATLMFC/LIB;C:/Program Files/Microsoft SDKs/Windows/v7.0A/lib;
SET LIBPATH=C:/Windows/Microsoft.NET/Framework/v4.0.30319;C:/Windows/Microsoft.NET/Framework/v3.5;C:/Program Files/Microsoft Visual Studio 10.0/VC/LIB;C:/Program Files/Microsoft Visual Studio 10.0/VC/ATLMFC/LIB;
SET Path=C:/Program Files/Microsoft F#/v4.0/;C:/Program Files/Microsoft Visual Studio 10.0/VSTSDB/Deploy;C:/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/;C:/Program Files/Microsoft Visual Studio 10.0/VC/BIN;C:/Program Files/Microsoft Visual Studio 10.0/Common7/Tools;C:/Windows/Microsoft.NET/Framework/v4.0.30319;C:/Windows/Microsoft.NET/Framework/v3.5;C:/Program Files/Microsoft Visual Studio 10.0/VC/VCPackages;C:/Program Files/HTML Help Workshop;C:/Program Files/Microsoft Visual Studio 10.0/Team Tools/Performance Tools;C:/Program Files/Microsoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools;C:/Program Files/Microsoft SDKs/Windows/v7.0A/bin;C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem;C:/Windows/System32/WindowsPowerShell/v1.0/;c:/Program Files/Microsoft SQL Server/100/Tools/Binn/;c:/Program Files/Microsoft SQL Server/100/DTS/Binn/
SET WindowsSdkDir=C:/Program Files/Microsoft SDKs/Windows/v7.0A/
SET PATH=C:/BuildJDK/Make;%PATH%;C:/BuildJDK/MSVCR100;C:/BuildJDK/Ant/bin;C:/BuildJDK/Cygwin/cygwin/bin;C:/BuildJDK/JDK/Java/jdk1.7.0_51/bin
SET INCLUDE=%INCLUDE%C:/BuildJDK/MSDXSDK/June2010/Include;C:/BuildJDK/Cygwin/cygwin/usr/include;C:/BuildJDK/FreeType/include;C:/BuildJDK/FreeType/include/freetype;
SET LIB=%LIB%C:/BuildJDK/Ant/lib;C:/BuildJDK/FreeType/objs/win32/vc2010;C:/BuildJDK/JDK/Java/jdk1.7.0_51/lib;C:/BuildJDK/MSDXSDK/June2010/Lib/x86;
SET LIBPATH=%LIBPATH%C:/BuildJDK/Ant/lib;C:/BuildJDK/FreeType/objs/win32/vc2010;C:/BuildJDK/JDK/Java/jdk1.7.0_51/lib;C:/BuildJDK/MSDXSDK/June2010/Lib/x86;
SET ALT_DXSDK_PATH=C:/BuildJDK/MSDXSDK/June2010
SET ALT_COMPILER_PATH=C:/Program Files/Microsoft Visual Studio 10.0/VC/bin
SET ALT_BOOTDIR=C:/BuildJDK/JDK/Java/jdk1.7.0_51
SET ALT_JDK_IMPORT_PATH=C:/BuildJDK/JDK/Java/jdk1.7.0_51
SET ALT_CYGWIN_PATH=C:/BuildJDK/Cygwin/cygwin
SET ALT_FREETYPE_LIB_PATH=C:/BuildJDK/FreeType/objs/win32/vc2010
SET ALT_FREETYPE_HEADERS_PATH=C:/BuildJDK/FreeType/include
SET ALT_DROPS_DIR=C:/BuildJDK/OpenJDK/drops
SET ALT_MSVCRNN_DLL_PATH=C:/BuildJDK/MSVCR100
SET ZIP_DEBUGINFO_FILES=0
SET FULL_DEBUG_SYMBOLS=1
SET HOTSPOT_BUILD_JOBS=2
SET PARALLEL_COMPILE_JOBS=2
SET ALLOW_DOWNLOADS=true
SET DEBUG_NAME=debug
SET BUILD_CORBA=false
SET LANG=C
SET INCLUDE=C:/Program Files/Microsoft Visual Studio 10.0/VC/INCLUDE;C:/Program Files/Microsoft Visual Studio 10.0/VC/ATLMFC/INCLUDE;C:/Program Files/Microsoft SDKs/Windows/v7.0A/include;
SET LIB=C:/Program Files/Microsoft Visual Studio 10.0/VC/LIB;C:/Program Files/Microsoft Visual Studio 10.0/VC/ATLMFC/LIB;C:/Program Files/Microsoft SDKs/Windows/v7.0A/lib;
SET LIBPATH=C:/Windows/Microsoft.NET/Framework/v4.0.30319;C:/Windows/Microsoft.NET/Framework/v3.5;C:/Program Files/Microsoft Visual Studio 10.0/VC/LIB;C:/Program Files/Microsoft Visual Studio 10.0/VC/ATLMFC/LIB;
SET Path=C:/Program Files/Microsoft F#/v4.0/;C:/Program Files/Microsoft Visual Studio 10.0/VSTSDB/Deploy;C:/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/;C:/Program Files/Microsoft Visual Studio 10.0/VC/BIN;C:/Program Files/Microsoft Visual Studio 10.0/Common7/Tools;C:/Windows/Microsoft.NET/Framework/v4.0.30319;C:/Windows/Microsoft.NET/Framework/v3.5;C:/Program Files/Microsoft Visual Studio 10.0/VC/VCPackages;C:/Program Files/HTML Help Workshop;C:/Program Files/Microsoft Visual Studio 10.0/Team Tools/Performance Tools;C:/Program Files/Microsoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools;C:/Program Files/Microsoft SDKs/Windows/v7.0A/bin;C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem;C:/Windows/System32/WindowsPowerShell/v1.0/;c:/Program Files/Microsoft SQL Server/100/Tools/Binn/;c:/Program Files/Microsoft SQL Server/100/DTS/Binn/
SET WindowsSdkDir=C:/Program Files/Microsoft SDKs/Windows/v7.0A/
SET PATH=C:/BuildJDK/Make;%PATH%;C:/BuildJDK/MSVCR100;C:/BuildJDK/Ant/bin;C:/BuildJDK/Cygwin/cygwin/bin;C:/BuildJDK/JDK/Java/jdk1.7.0_51/bin
SET INCLUDE=%INCLUDE%C:/BuildJDK/MSDXSDK/June2010/Include;C:/BuildJDK/Cygwin/cygwin/usr/include;C:/BuildJDK/FreeType/include;C:/BuildJDK/FreeType/include/freetype;
SET LIB=%LIB%C:/BuildJDK/Ant/lib;C:/BuildJDK/FreeType/objs/win32/vc2010;C:/BuildJDK/JDK/Java/jdk1.7.0_51/lib;C:/BuildJDK/MSDXSDK/June2010/Lib/x86;
SET LIBPATH=%LIBPATH%C:/BuildJDK/Ant/lib;C:/BuildJDK/FreeType/objs/win32/vc2010;C:/BuildJDK/JDK/Java/jdk1.7.0_51/lib;C:/BuildJDK/MSDXSDK/June2010/Lib/x86;
SET ALT_DXSDK_PATH=C:/BuildJDK/MSDXSDK/June2010
SET ALT_COMPILER_PATH=C:/Program Files/Microsoft Visual Studio 10.0/VC/bin
SET ALT_BOOTDIR=C:/BuildJDK/JDK/Java/jdk1.7.0_51
SET ALT_JDK_IMPORT_PATH=C:/BuildJDK/JDK/Java/jdk1.7.0_51
SET ALT_CYGWIN_PATH=C:/BuildJDK/Cygwin/cygwin
SET ALT_FREETYPE_LIB_PATH=C:/BuildJDK/FreeType/objs/win32/vc2010
SET ALT_FREETYPE_HEADERS_PATH=C:/BuildJDK/FreeType/include
SET ALT_DROPS_DIR=C:/BuildJDK/OpenJDK/drops
SET ALT_MSVCRNN_DLL_PATH=C:/BuildJDK/MSVCR100
SET ZIP_DEBUGINFO_FILES=0
SET FULL_DEBUG_SYMBOLS=1
SET HOTSPOT_BUILD_JOBS=2
SET PARALLEL_COMPILE_JOBS=2
SET ALLOW_DOWNLOADS=true
SET DEBUG_NAME=debug
SET BUILD_CORBA=false
SET LANG=C
上面所有操作都完成后,将
上述env.txt文件的文件名更改成env.bat,并在打开的CMD中执行之:
12.编译OpenJDK7
bash
export WINDOWSSDKDIR=$WindowsSDKDir
make sanity 2>&1 | tee c:/BuildJDK/make_sanity_x86.log
make 2>&1 | tee c:/BuildJDK/make_x86.log
打开bash,进入Cygwin:
设置bash中的环境变量:
export WINDOWSSDKDIR=$WindowsSDKDir
执行编译检测命令,查看配置是否成功:
make sanity 2>&1 | tee c:/BuildJDK/make_sanity_x86.log
开始检测:
检测完毕:
当出现Sanity check passed后,就可以执行下面的命令进行编译了:
make 2>&1 | tee c:/BuildJDK/make_x86.log
开始编译:
编译完成:
编译完成后,日志文件在
c:\BuildJDK\make_sanity_x86.log和
c:\BuildJDK\make_x86.log中。
编译后的JDK镜像位于C:\BuildJDK\OpenJDK\build\windows-i586目录中
13、构建VS2010下的OpenJDK7调试环境
将C:\BuildJDK\OpenJDK\hotspot\make\windows\create.bat文件中的如下脚本注掉:
cl 2>NUL >NUL if %errorlevel% == 0 goto nexttest
echo Make sure cl.exe is in your PATH before running this script.
goto end
:nexttest
grep -V 2>NUL >NUL
if %errorlevel% == 0 goto testit
echo Make sure grep.exe is in your PATH before running this script. Either cygwin or MKS should work.
goto end
注掉后:
打开一个CMD窗口,在C:\BuildJDK\OpenJDK\hotspot\make\windows文件夹下构建OpenJDK7工程文件:
cd /d C:\BuildJDK\OpenJDK\hotspot\make\windows "C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat"
SET JAVA_HOME=C:\BuildJDK\OpenJDK\build\windows-i586
SET PATH=C:\BuildJDK\OpenJDK\build\windows-i586\bin;%PATH%;C:\BuildJDK\Make;C:\BuildJDK\Cygwin\cygwin\bin;
SET HOTSPOTMKSHOME=C:\BuildJDK\Cygwin\cygwin\bin
create.bat ../../../build/windows-i586
开始构建:
构建完成:
构建完成后,OpenJDK7的工程目录位于C:\BuildJDK\OpenJDK\hotspot\build\vs-i486目录中:
打开jvm.vcxproj文件即可:
编译:
成功后,在\src\share\vm\runtime\thread.cpp中的
Threads::create_vm()打断点即可调试JVM了:
14、构建VS相对路径
通过上面的方法,可以搭建OpenJDK7的VS2010调试环境,但是该环境中的所有目录路径都是绝对的,如果将C:\BuildJDK\OpenJDK目录移动到其它目录或者更改一下它的名称,则会导致VS2010出现编译错误,因此,也有必要更改VS2010中的一些配置参数,将这些路径通过环境变量来控制,以实现在任意目录中均可编译成功,具体如下:
构建环境变量:
HOTSPOT_PATH指向OpenJDK源代码目录下的hotspot目录:
HOTSPOT_PATH=
C:\BuildJDK\OpenJDK\hotspot
CYGWIN_PATH指向Cygwin的安装目录:
CYGWIN_PATH=
C:\BuildJDK\Cygwin\cygwin
修改工程文件引用:
在修改之前,最好备份工程文件。
用文本编辑器打开C:\BuildJDK\OpenJDK\hotspot\build\vs-i486\jvm.vcxproj文件,将该文件
中的"C:\BuildJDK\OpenJDK\hotspot"全部替换为"$(HOTSPOT_PATH)",将"C:\BuildJDK\Cygwin\cygwin"全部替换为"$(CYGWIN_PATH)"。
修改后,保存退出即可。
修改Makefile相对路径:
用文本编辑器打开C:\BuildJDK\OpenJDK\hotspot\make\windows\projectfiles\common\
Makefile文件,在文件中首次出现HOTSPOTWORKSPACE变量的地方(本文为第30行)的上一行(本文为第29行)处添加HOTSPOTWORKSPACE变量,让其指向上面设置的环境变量
HOTSPOT_PATH
,例如:"
HOTSPOTWORKSPACE=$(HOTSPOT_PATH)
":
设置后:
保存退出即可。
15、相对路径测试
为了检测是否能够在任意目录编译成功,可以将C:\BuildJDK目录下的
OpenJDK文件夹重命名为
OpenJDK_T,同时
将C:\BuildJDK目录下的
Cygwin文件夹重命名为Cygwin_T,同时修改系统的环境变量:
HOTSPOT_PATH=
C:\BuildJDK\OpenJDK_T\hotspot、
CYGWIN_PATH=
C:\BuildJDK\Cygwin_T\cygwin。
打开C:\BuildJDK\OpenJDK_T\hotspot\build\vs-i486\jvm.vcxproj工程文件,然后编译,变成成功后,提示如下:
注意,如果在编译的过程中,如果出现静态库的链接错误,
打开%HOTSPOT_PATH%\src\os\windows\vm\os_windows.cpp文件,向该文件中添加如下内容即可:
#include <Psapi.h>
#pragma comment ( lib, "psapi.lib" )
16、打包
将
C:\BuildJDK目录下的OpenJDK和Cygwin目录打包,将该包解压到任意Win32环境下,并配置相应的
HOTSPOT_PATH和
CYGWIN_PATH环境变量,即可在任意机器的任意目录中使用Visual Studio调试OpenJDK7u40的代码了。
DXSDK_Jun10.exe:http://www.microsoft.com/en-us/download/details.aspx?id=6812
en_visual_studio_2010_ultimate_x86_dvd_509116.iso:http://www.itellyou.cn/
jdk-7u51-windows-i586.exe:http://www.oracle.com/technetwork/java/javase/downloads/index.html
apache-ant-1.9.4-bin.zip:http://ant.apache.org/
Cygwin-x86:http://www.cygwin.com/install.html
make-3.82.tar.gz:http://ftp.gnu.org/gnu/make/
freetype-2.5.0.1.tar.gz:http://sourceforge.net/projects/freetype/files/freetype2/2.5.0/
openjdk-7u40-fcs-src-b43-26_aug_2013.zip:http://download.java.net/openjdk/
jaxp-1_4_5-unittests.zip:http://download.java.net/jaxp/1.4.5
jaxp145_01.zip:http://download.java.net/jaxp/1.4.5
jdk7-jaxws2_2_4-b03-2011_05_27.zip:http://download.java.net/glassfish/components/jax-ws/openjdk/jdk7
jdk7-jaf-2010_08_19.zip:https://java.net/downloads/jax-ws/JDK7/
https://weblogs.java.net/blog/simonis/archive/2011/10/28/yaojowbi-yet-another-openjdk-windows-build-instruction
http://betoweb.com.br/blog/2013/07/12/building-openjdk-on-ms-windows-8/
http://www.javacodegeeks.com/2012/09/stass-blog-building-openjdk-on-windows.html
https://www.mail-archive.com/build-dev@openjdk.java.net/msg05014.html
http://www.sunnychan.hk/roller/sunny/entry/how_to_compile_openjdk_on
http://markmail.org/message/5uycurv63qv5nf2s
http://www.tuicool.com/articles/A7jUfe
https://github.com/codefollower/OpenJDK-Research
http://blog.csdn.net/gnefniu/article/details/7515394
https://blogs.oracle.com/poonam/entry/how_to_create_vc_project
17、下载链接
Windows 7 32bit:http://www.itellyou.cn/DXSDK_Jun10.exe:http://www.microsoft.com/en-us/download/details.aspx?id=6812
en_visual_studio_2010_ultimate_x86_dvd_509116.iso:http://www.itellyou.cn/
jdk-7u51-windows-i586.exe:http://www.oracle.com/technetwork/java/javase/downloads/index.html
apache-ant-1.9.4-bin.zip:http://ant.apache.org/
Cygwin-x86:http://www.cygwin.com/install.html
make-3.82.tar.gz:http://ftp.gnu.org/gnu/make/
freetype-2.5.0.1.tar.gz:http://sourceforge.net/projects/freetype/files/freetype2/2.5.0/
openjdk-7u40-fcs-src-b43-26_aug_2013.zip:http://download.java.net/openjdk/
jaxp-1_4_5-unittests.zip:http://download.java.net/jaxp/1.4.5
jaxp145_01.zip:http://download.java.net/jaxp/1.4.5
jdk7-jaxws2_2_4-b03-2011_05_27.zip:http://download.java.net/glassfish/components/jax-ws/openjdk/jdk7
jdk7-jaf-2010_08_19.zip:https://java.net/downloads/jax-ws/JDK7/
18、参考链接
http://hg.openjdk.java.net/jdk7/build/raw-file/tip/README-builds.htmlhttps://weblogs.java.net/blog/simonis/archive/2011/10/28/yaojowbi-yet-another-openjdk-windows-build-instruction
http://betoweb.com.br/blog/2013/07/12/building-openjdk-on-ms-windows-8/
http://www.javacodegeeks.com/2012/09/stass-blog-building-openjdk-on-windows.html
https://www.mail-archive.com/build-dev@openjdk.java.net/msg05014.html
http://www.sunnychan.hk/roller/sunny/entry/how_to_compile_openjdk_on
http://markmail.org/message/5uycurv63qv5nf2s
http://www.tuicool.com/articles/A7jUfe
https://github.com/codefollower/OpenJDK-Research
http://blog.csdn.net/gnefniu/article/details/7515394
https://blogs.oracle.com/poonam/entry/how_to_create_vc_project