centos7编译openjdk记录

Posted 技术小叮铛

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7编译openjdk记录相关的知识,希望对你有一定的参考价值。

网上很多文章关于编译jdk,尤其是openjdk8的文章,但是套路基本差不多,有需要的话可以先搜索一大筐大体了解一下!
下面说下本人进行的操作,整体参考:https://zhoupinheng.iteye.com/blog/2428274
以上链接仅做参考,因为是不能顺利执行下去的,至少我是!

先说一下我的环境:
Linux version 3.10.0-957.1.3.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 29 14:49:43 UTC 2018

执行这句进行构建的时候,bash ./configure --with-target-bits=64 --disable-warnings-as-errors 报出问题:

configure: Could not find a valid Boot JDK. You might be able to fix this by running 'sudo yum install java-1.8.0-openjdk-devel'.
configure: This might be fixed by explicitly setting --with-boot-jdk
configure: error: Cannot continue
configure exiting with result code 1

表示没有引导JDK,然后下载jdk-8u192-linux-x64.tar.gz ,执行bash ./configure --with-target-bits=64 --with-boot-jdk=/home/kevin/Java/jdk1.8.0_192 --disable-warnings-as-errors,结果执行继续报错 :

configure: Found potential Boot JDK using configure arguments
configure: Potential Boot JDK found at /home/kevin/Java/jdk1.8.0_192 is incorrect JDK version (java version "1.8.0_192"); ignoring
configure: (Your Boot JDK version must be one of: 11 12 13)
configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK
configure exiting with result code 1

好麻,先下载个JDK11再说!https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
继续替换引导JDK的路径和版本:bash ./configure --with-target-bits=64 --with-boot-jdk=/home/kevin/Java/jdk-11.0.1 --disable-warnings-as-errors
继续报错:

configure: error: Could not find all X11 headers (shape.h Xrender.h Xrander.h XTest.h Intrinsic.h). You might be able to fix this by running 'sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel'.
configure exiting with result code 1

这些只是需要根据提示进行升级之类的就可以了,最后执行成功如下:

====================================================
A new configuration has been successfully created in
/opt/openjdk10/openjdk/build/linux-x86_64-server-release
using configure arguments '--with-target-bits=64 --with-boot-jdk=/home/kevin/Java/jdk-11.0.1 --disable-warnings-as-errors'.

Configuration summary:
* Debug level: release
* HS debug level: product
* JVM variants: server
* JVM features: server: 'aot cds cmsgc compiler1 compiler2 epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services shenandoahgc vm-structs zgc'
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64
* Version string: 13-internal+0-adhoc.kevin.openjdk (13-internal)

Tools summary:
* Boot JDK: java version "11.0.1" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode) (at /home/kevin/Java/jdk-11.0.1)
* Toolchain: gcc (GNU Compiler Collection)
* C Compiler: Version 4.8.5 (at /usr/bin/gcc)
* C++ Compiler: Version 4.8.5 (at /usr/bin/g++)

Build performance summary:
* Cores to use: 1
* Memory limit: 2827 MB

最后执行make all,最后进入漫长的编译等待。当出现如下所示,表示成功:

Finished building target 'all' in configuration 'linux-x86_64-server-release'

使用Clion调试Hotspot
感谢该问作者,写得相当不错!尤其是目前这方面的资料还是挺少的,https://www.jianshu.com/p/ee7e9176632c


以上是关于centos7编译openjdk记录的主要内容,如果未能解决你的问题,请参考以下文章

Centos7编译openjdk7

[转]CentOS7下编译openjdk

Centos7 下编译 Openjdk8

centos7编译JDK

修改,编译,GDB调试openjdk8源码(docker环境下)

修改,编译,GDB调试openjdk8源码(docker环境)