Compile openjdk7 in Windows

Source: Internet
Author: User

Compiling openjdk in Windows is a difficult process...

Platform: WindowsXP + cygwin, openjdk version: openjdk7, compiler: vs2010

Openjdk7 is selected because openjdk6 does not support vs2010. openjdk7 considers vs2010.

I will not detail the process because it is a long one. Similar to code download and cygwin installation, please follow the compilation instructions on the openjdk official website. Let me talk about the problems encountered during the compilation process (the following path is used "~ "Represents my openjdk7 source code to store the root directory ).

 

1. JDK version Problems

For stability, I downloaded JDK 6 of RC (Release Candidate) as the bootstrap JDK from Sun's website. However, when openjdk uses Sun JDK's javac, it uses non-standard parameters... that is to say, openjdk compilation can only use sun's jdk6 as the bootstrap JDK, and it must also be a development version, not a stable version (RC version does not include these extensions ).

I had to reinstall Sun's 6u23 JDK.

 

2. Make version of cygwin

Okay, as shown in the openjdk compilation instructions, cygwin's make may use version 3.8.0. However, during compilation, the openjdk printing information indicates that make of 3.8.1 is the recommended "lowest" version! It turns out to be a second message. Install Version 3.8.0 honestly and ignore this warning.

 

3. environment variable settings

Before compiling, enter ~ /JDK/make: Run jdk_generic_profile.sh. However, this batch processing only takes vs2003 into account, and subsequent vs versions are not considered and need to be modified.

In fact, setting environment variables takes the most time. I will list my changes directly (the following information is the difference obtained using the cygwin diff command)

113c113
<Importjdk = jdk1.7.0
---
> Importjdk = jdk1.6.0
167d166
<
169,170 d167
<Jdk_instances = "C :"
<
195a193, 207
> Export include = "D:/program files/Microsoft Visual Studio 10.0/VC/include; C:/program files/Microsoft sdks/Windows/v7.0a/include; D: /program files/Microsoft Visual Studio 10.0/VC/atlmfc/include"
> Export Lib = "D:/program files/Microsoft Visual Studio 10.0/VC/LIB; C:/program files/Microsoft sdks/Windows/v7.0a/LIB; D: /openjdk-7/FreeType/bin; D:/program files/Microsoft Visual Studio 10.0/VC/atlmfc/lib"
> Export alt_binary_plugs_path =$ ($ {cygpath} "D:/openjdk-7/openjdk-binary-Plugs ")
> Export alt_compiler_path =$ ($ {cygpath} "D:/program files/Microsoft Visual Studio 10.0/VC/bin ")
> Export alt_bootdir =$ ($ {cygpath} "D:/program files/Java/jdk1.6.0 ")
> Export alt_jdk_import_path =$ {alt_bootdir}
> Export alt_freetype_lib_path = $ ($ {cygpath} "D:/openjdk-7/FreeType/lib ")
> Export alt_freetype_headers_path =$ ($ {cygpath} "D:/openjdk-7/FreeType/include ")
> Export alt_msdevtools_path =$ ($ {cygpath} "C:/program files/Microsoft sdks/Windows/v7.0a/bin ")
> Export alt_cc_ver = 16.00.30319.01
> Export alt_msc_ver_raw = 16.00.30319.01
> Export ant_home =$ ($ {cygpath} "D:/openjdk-7/Apache-ant-1.8.2 ")
> Export allow_downloads = true
> Export lang = C
> Jdk_instances =$ ($ {cygpath} "D:/program files/Java ")
221,222 c233, 234
<# Visualstudio. NET 2003 VC ++ 7.1 (vs71comntools shocould be defined)
<Vs_root =$ ($ {cygpath} "$ {vs71comntools }/../..")
---
> # Visualstudio 2010 (vs100comntools shocould be defined)
> Vs_root =$ ($ {cygpath} "$ {vs100comntools }/../..")
224c236
<Msdev_root = "$ {vs_root}/common7/tools"
---
> Msdev_root =$ ($ {cygpath} "C:/program files/Microsoft sdks/Windows/v7.0a ")
226,228 c238, 240
<Vc7_root = "$ {vs_root}/vc7"
<Compiler_path = "$ {vc7_root}/bin"
<Platform_sdk = "$ {vc7_root}/platformsdk"
---
> Vc_root = "$ {vs_root}/VC"
> Compiler_path = "$ {vc_root}/bin"
> Platform_sdk =$ {msdev_root}
231,233 c243, 245
<Shortde4sdk = "$ {vc7_root}/atlmfc/include"
<Shortde4sdk = "$ {shortde4sdk}; $ {vc7_root}/include"
<Shortde4sdk = "$ {shortde4sdk}; $ {platform_sdk}/include/prerelease"
---
> Include4sdk = "$ {vc_root}/atlmfc/include"
> Include4sdk = "$ {include4sdk}; $ {vc_root}/include"
> # Include4sdk = "$ {include4sdk}; $ {platform_sdk}/include/prerelease"
235,237 c247, 249
<Shortde4sdk = "$ {shortde4sdk}; $ {vs_root}/SDK/V1.1/include"
<Lib4sdk = "$ {lib4sdk}; $ {vc7_root}/lib"
<Lib4sdk = "$ {lib4sdk}; $ {platform_sdk}/lib/prerelease"
---
> # Include4sdk = "$ {include4sdk}; $ {vs_root}/SDK/V1.1/include"
> Lib4sdk = "$ {lib4sdk}; $ {vc_root}/lib"
> # Lib4sdk = "$ {lib4sdk}; $ {platform_sdk}/lib/prerelease"
239c0000, 252
<Lib4sdk = "$ {lib4sdk}; $ {vs_root}/SDK/V1.1/lib"
---
> Lib4sdk = "$ {lib4sdk}; $ {vc_root}/atlmfc/lib"
> # Lib4sdk = "$ {lib4sdk}; $ {vs_root}/SDK/V1.1/lib"
242,243 c255, 256
<Path4sdk = "$ {vs_root}/common7/tools/bin; $ {path4sdk }"
<Path4sdk = "$ {vs_root}/SDK/V1.1/bin; $ {path4sdk }"
---
> # Path4sdk = "$ {vs_root}/common7/tools/bin; $ {path4sdk }"
> # Path4sdk = "$ {vs_root}/SDK/V1.1/bin; $ {path4sdk }"
245c258
<Path4sdk = "$ {vs_root}/common7/tools/bin/prerel.pdf; $ {path4sdk }"
---
> # Path4sdk = "$ {vs_root}/common7/tools/bin/prerel.pdf; $ {path4sdk }"
247a261
> Path4sdk = "$ {msdevtools_path}; $ {path4sdk }"
339a354

> Path = $ path: $ ant_home/bin

 

If you are not familiar with the diff command output format of cygwin, You can query it online. Each user needs to modify the settings based on their own platform environment.

Here are some environment variable settings (alt_cc_ver and alt_msc_ver_raw) that are not mentioned in openjdk compilation instructions. Their functions are described later.

In addition, do not forget to set allow_downloads = true to allow missing third-party class files to be downloaded during compilation.

 

4. vs2010 language problems

Is vs2010 an English version? If yes, skip this line.

In openjdk's Analysis of vcpus, cl.exe is executed without the command line. The version number is analyzed from the output version description by matching the keyword "version ". The Chinese version vs is tragic. The version description is Chinese, and there is no such English text...

If you change the keyword to Chinese for analysis, the English version of VS is no longer effective. The alt_cc_ver and alt_msc_ver_raw variables have to be set. This means that if the VC version number is not specified externally, the keyword analysis method is used to obtain the version number.

Involved files include ~ /Hotspot/make/Windows/get_msc_ver.sh and ~ /JDK/make/common/shared/Compiler-msvc.gmk

The change to get_msc_ver.sh is:

61c61, 66
<Msc_ver_raw = 'cl 2> & 1 | "$ head"-N 1 | "$ sed"'s /. * version [/] */([0-9] [0-9.] */). * // 1 /''
---
> # Msc_ver_raw = 'cl 2> & 1 | "$ head"-N 1 | "$ sed"'s /. * version [/] */([0-9] [0-9.] */). * // 1 /''
> If ["$ {alt_msc_ver_raw }"! = ""]; Then
> Msc_ver_raw =$ {alt_msc_ver_raw}
> Else
> Msc_ver_raw = 'cl 2> & 1 | "$ head"-N 1 | "$ sed"'s /. * version [/] */([0-9] [0-9.] */). * // 1 /''
> Fi

 

The change to Compiler-msvc.gmk is

49, 50c49, 53
<Cc_ver: = $ (shell $ (CC) 2> & 1 | $ (head)-N 1 | $ (SED)'s /. */(version. */) // 1/'| $ (nawk)' {print $2 }')
<
---
> Ifdef alt_cc_ver
> Cc_ver: = $ (alt_cc_ver)
> Else
> Cc_ver: = $ (shell $ (CC) 2> & 1 | $ (head)-N 1 | $ (SED)'s /. */(version. */) // 1/'| $ (nawk)' {print $2 }')
> Endif

5. Install jdk-7-ea-plug-b123-windows-i586-22_dec_2010.jar

Here is just a reminder, don't forget to install this thing (I forgot to install it ...). Openjdk Official Website
Download is available.

I installed ~ /Openjdk-binary-plugs/

 

6. Install FreeType Library

Due to the manifest problem of freetypechecker used during openjdk compilation, vs2010 must be used for re-encoding. FreeType dll must be used for running this tool (in fact, FreeType is also used for openjdk, but the project does not contain the relevant library files ). Download the binary file from FreeType official website (although the source code is also provided for download, but there is really no effort to get involved...), install it ~ /FreeType. Note:

1). FreeType is the latest version (2.3.5). The library has been renamed. It is not called FreeType. dll, but freetype6.dll. At the same time, there is an additional dependent library! Zlib1.dll. This library does not work with FreeType and needs to be downloaded separately. Do not forget it.

2). openjdk7 requires that FreeType. lib and FreeType. dll be placed in a directory. This is not the default setting of the FreeType project. You need to manually copy freetype6.dll and zlib1.dll to the directory where FreeType. Lib is located (~ /FreeType/lib /).

3). Because the FreeType library name has changed, you need to modify the makefile and Java source files (considering that the subsequent versions of the FreeType library will not be called back to FreeType. dll, we recommend that you modify the openjdk project ).

Involved files include ~ /JDK/make/Sun/font/makefile ,~ /JDK/make/tools/freetypecheck/makefile and ~ /JDK/src/share/classes/Sun/font/fontmanagernativelibrary. Java

~ /JDK/make/Sun/font/makefile:

126c126, 127
<Freetype_lib = $ (lib_location)/$ (lib_prefix) FreeType. $ (library_suffix)
---
> Freetype_lib = $ (lib_location)/$ (lib_prefix) freetype6. $ (library_suffix)
> Zlib1_lib = $ (lib_location)/$ (lib_prefix) zlib1. $ (library_suffix)
137,138 c138, 142
<$ (Freetype_lib ):
<$ (CP) $ (freetype_lib_path)/$ (lib_prefix) FreeType. $ (library_suffix) $ @
---
> $ (Freetype_lib): $ (zlibpoliclib)
> $ (CP) $ (freetype_lib_path)/$ (lib_prefix) freetype6. $ (library_suffix) $ @
> $ (Install-module-file)
>$ (Zlib1_lib ):
> $ (CP) $ (freetype_lib_path)/$ (lib_prefix) zlib1. $ (library_suffix) $ @

 

~ /JDK/make/tools/freetypecheck/makefile:

41c41, 42
<Freetype_dll = $ (freetype_lib_path)/FreeType. dll
---
> Freetype_dll = $ (freetype_lib_path)/freetype6.dll
> Zlib1_dll = $ (freetype_lib_path)/zlib1.dll
72a74
> $ (CP) $ (zlib1_dll) $ (@ d )/

 

The change to fontmanagernativelibrary. Java is

59c59, 60
<System. loadlibrary ("FreeType ");
---
> // System. loadlibrary ("FreeType ");
> System. loadlibrary ("freetype6 ");

 

7. Default javac Encoding Problems

I don't know why. Some java files automatically generated by openjdk are annotated in Chinese. Javac specifies the ASCII encoding method (the parameter-encoding ASCII is added ). Javac reports an error when a Java file contains Chinese characters. Remove the-encoding compilation option and use the default encoding of the operating system to solve the problem.

Involved files include ~ /CORBA/make/common/shared/Defs-java.gmk ,~ /JDK/make/common/shared/Defs-java.gmk and ~ /Hotspot/make/Windows/makefiles/rules. Make

~ /CORBA/make/common/shared/the change to the Defs-java.gmk is

133c133
<Javacflags + =-encoding ASCII
---
> # Javacflags + =-encoding ASCII
194c194, 195
<Boot_javacflags + =-encoding ascii-source $ (boot_source_language_version)-target $ (boot_target_class_version)
---
> # Boot_javacflags + =-encoding ascii-source $ (boot_source_language_version)-target $ (boot_target_class_version)
> Boot_javacflags + =-source $ (boot_source_language_version)-target $ (boot_target_class_version)

 

~ /JDK/make/common/shared/Defs-java.gmk changes are

134c134
<Javacflags + =-encoding ASCII
---
> # Javacflags + =-encoding ASCII
212c212, 213
<Boot_javacflags + =-encoding ascii-source $ (boot_source_language_version)-target $ (boot_target_class_version)
---
> # Boot_javacflags + =-encoding ascii-source $ (boot_source_language_version)-target $ (boot_target_class_version)
> Boot_javacflags + =-source $ (boot_source_language_version)-target $ (boot_target_class_version)

The change to rules. Make is:

48c48, 49
<Javac_flags =-g-encoding ASCII
---
> # Javac_flags =-g-encoding ASCII
> Javac_flags =-G

 

8. VC warning Problems

I don't know about the confidence in openjdk. I have enabled the "think warning as error" (warnings as errors) option of VC. In my case, the openjdk source code uses a deprecated
), Generates warning information. It is too risky to change the source code, so I adjusted the compilation options. Involved files include ~ /Hotspot/make/Windows/makefiles/compile. Make and ~ /Hotspot/src/share/tools/hsdis/makefile

The change to compile. Make is:

53c53, 54
<Cpp_flags =/nologo/W3/wx
---
> # Cpp_flags =/nologo/W3/wx
> Cpp_flags =/nologo/W3/wx-

 

The makefile is modified as follows:

92c92, 93
<Cflags + =/nologo/MD/W3/wx/O2/fo $ (@:. dll =. OBJ)/Gi-
---
> # Cflags + =/nologo/MD/W3/wx/O2/fo $ (@:. dll =. OBJ)/Gi-
> Cflags + =/nologo/MD/W3/wx-/O2/fo $ (@:. dll =. OBJ)/Gi-

 

 

Only these problems are recorded, and some omissions may occur. When compiling your own openjdk, you may not have encountered any problems. I hope my experience will be helpful to you if I cannot solve the problem.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.