This is the 25th day of my participation in the August Challenge
Build OpenJDK8 in Win10
Compile environment
- Windows10 pro 64-bit;
Preparation before compilation
Tip: The following software installation and decompression directory should not contain Chinese or space, otherwise there may be problems
- Install Visual Studio 2010 Professional
To compile the JDK for Windows, you need to use Visual Studio 2010 Professional, msdn.itellyou.cn
It is best to download the IDE in English, otherwise there may be problems, just check the install C++ section after downloading
- Prepare OpenJDK8
Download OpenJDK8, recommend download address: download.java.net/openjdk/jdk… After downloading, decompress
- Compile the JDK environment installation (skip this section if you already have it installed)
-
To compile the OpenJDK, you need to install the JDK on the host first, and use the JDK of the previous version. To compile the OpenJDK8, you need to install JDK7 Update 7 or later.
-
Download Oracle JDK7 and unzip it.www.oracle.com/technetwork…
After downloading, configure JDK environment variables (JAVA_HOME, Path, CLASspath)
- Install Cygwin
-
Compiling the JDK requires the use of tools on Unix and Linux, and Cygwin can run these on Windows.
-
Recommended download address:www.cygwin.com/
Download the latest version of Cygwin and install it. Since the default installation only installs necessary software, you need to select some additional packages during the installation process. The required packages are shown below:
If you have installed The Cygwin software and want to continue installing other packages, you can run the Cygwin installer again and make sure that the local Cygwin installation directory is selected. Click Next until the screen for selecting the installation package appears.
- To prepare the FreeType 2.7
-
To compile the JDK, you need FreeType, a font rendering library not mentioned in the official documentation, but required.
-
It is best to use version 2.7, I had problems using the newer version earlier.
-
Recommended download address:www.freetype.org/, decompress after downloading:www.freetype.org/download.ht…
-
Run Visual Studio 2010 and go to File -> Open -> Project/Solution
- Choose to open the freetype-2.7\builds\ Windows \vc2010\freetype.sln file
- After selecting the project, right click to select Properties, and the operation window will pop up as follows:
Click Apply and then click OK to close the window, right click the project and click Build button to compile the lib file successfully.
Right-click the project again and click the Properties button to bring up the window.
Click Apply and then click OK to close the window. Right click the project and click the Build button to successfully compile the DLL file.
Copy freetype.lib and freetype. DLL files from freetype-2.7objs vc2010 x64 to freetype-2.7/
Begin to compile
- Generate a compile configuration script
Run Cygwin, CD to OpenJDK8 root directory
Tip: Directories in Cygwin can be marked as Windows directories, such as’ D:\DirName\file.txt ‘, which must be surrounded by single quotes, or Linux like: / cygdrive/d/DirName/file. TXT, it is recommended to use after a way better compatibility.
Enter the following command:
/configure --with-freetype= freetype-2.7/ --with-target-bits=64 --enable-debug
Copy the code
Note that the above freetype path is replaced by the path on your local machine.
- Compile the JDK
Switch to the root directory of the Open JDK for Cygwin and run the following command
make all
Copy the code
After the command is executed, the compilation process may take a long time. Depending on the machine performance, the following information is displayed after the compilation is successful:
- Verify the compilation result
Jtreg is required to perform regression tests, but this test is cumbersome and time-consuming, so ignore running cmd.exe. Go to openjdk8\build\windows-x86_64-normal-server-fastdebug\ JDK \bin and enter the following commands: openjdk8\build\windows-x86_64-normal-server-fastdebug\ JDK \bin
javac -version
java -version
Copy the code
Failure problem handling
- Cygwin is too old, but the version of Cygwin used is later than version 1.7.
- This is due to a problem with the script that OpenJDK8 comes with to generate the configuration.
- Openjdk8 \common\autoconf\generated-configure.sh: openjdk8\common\autoconf\generated-configure.sh: openjdk8 Comment out the if conditional statement
- Failed to compile the images library
An error occurred while compiling to the images library
Here insert pictures describe the error message shows a CreateJars. GMK error, consult relevant information is found after file need to add two carriage return, namely ‘\ r \’ said for CR this symbol.
- Open the createjars. GMK file in the OpenJDK directory with Notepad++
- Click view -> Show Symbols -> Show all symbols in the menu bar
- You can then see all the symbols, including newlines and carriage returns
Find the following place in the file:Add a return sign (Ctrl + M) between the two ‘class$$’ as shown below:Save the configuration, run the make clean command to clear the configuration, and run the make all command to compile the configuration
Refer to the article
The text was written and implemented with reference to the following blog posts or articles:
Blog.csdn.net/wqlinloveru… www.jianshu.com/p/e85f93cc7… Its source directory README – builds. HTML blog.csdn.net/qq0012520/a official document…