`

ubuntu 13.04环境编译OpenJDK7

 
阅读更多
从openjdk代码仓库下载源码

 

  1. 需要安装Mercurial(hg)版本管理工具。
    写道
    sudo apt-get install mercurial
     
  2. 安装Mercurial的hclone扩展插件:
    写道
    hg clone http://bitbucket.org/pmezard/hgforest-crew
      
  3. 将以下内容添加到$HOME/.hgrc文件中,如果没有则自己创建一个:
    写道
    [extensions]
    forest=/home/lichengwu/hgforest-crew/forest.py
    fetch=
     
  4. 下载jdk7源码:
    写道
    hg fclone http://hg.openjdk.java.net/jdk7/jdk7
    cd jdk7/ && sh get_source.sh
     
直接下载源码包[推荐]
写道
http://download.java.net/openjdk/jdk7u4/promoted/b22/
 

安装编译必须组件

 

  1. 安装gcc、g++、make等
    写道
    sudo apt-get install build-essential
     
  2. 安装ant 1.7以上
    写道
    sudo apt-get install ant
     
  3. 安装XRender
    写道
    sudo apt-get install libxrender-dev
    sudo apt-get install xorg-dev
     
  4. 安装alsa
    写道
    sudo apt-get install libasound2-dev
     
  5. Cups
    写道
    sudo apt-get install libcups2-dev
     
  6. 安装jdk6
    写道
    #一般ubuntu都自带,没有的话
    sudo apt-get install openjdk-6-jdk
     
  7. 我是使用的oracle的jdk6,可以编译成功

  8. 安装零碎的工具包
    写道
    sudo apt-get install gawk zip libxtst-dev libxi-dev libxt-dev

测试编译脚本:

写道
export LANG=C ALT_BOOTDIR=/usr/belleing/java
#disable JAVA_HOME
export -n JAVA_HOME
export ALT_JDK_IMPORT_PATH=/usr/belleing/java
make sanity BUILD_JAXWS=false BUILD_JAXP =false
 如果出现:Sanity check passed.则表示测试编译通过了,不过也别开心得太早,真正make的时候不保证一定没问题,也许还会缺少某些依赖。

编译脚本:

写道
#!/bin/bash
# cd jdk source code folder
cd ~/workspace/openjdk
# export ALT_BOOTDIR
export LANG=C ALT_BOOTDIR=/usr/belleing/java
# set build profile,first 'chmod +x jdk_generic_profile.sh'
jdk/make/jdk_generic_profile.sh
# disable JAVA_HOME
export -n JAVA_HOME
# export ALT_JDK_IMPORT_PATH
export ALT_JDK_IMPORT_PATH=/usr/belleing/java
# start build
export ALLOW_DOWNLOADS=true
make DEBUG_NAME=all_fastdebug
#make DEBUG_NAME=all_fastdebug BUILD_JAXWS=false BUILD_JAXP=false

   

下面就是解决make出现的各种问题和解决方案:

 

1.ERROR: You do not have access to valid Cups header files.
需要安装cpus的dev包

sudo apt-get install libcups2-dev

2.ERROR: The version of ant being used is older than the required version of '1.7.1'. The version of ant found was ''.
这说明没有装ant

sudo apt-get install ant

3. ERROR: FreeType version 2.3.0 or higher is required.

安装freetype的dev包

sudo apt-get install libfreetype6-dev

4. ERROR: You seem to not have installed ALSA 0.9.1 or higher.
不需要从ALSA官网下载alsa-dev和alsa-drive, ubuntu提供包的

sudo apt-get install libasound2-dev

5. ERROR: echo "*** This OS is not supported:" 'uname -a'; exit 1;
很奇怪的错误,anyway,注释掉hotspot/make/linux/Makefile里面的checkOS

check_os_version:
#ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
# $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
#endif


Update: 最好的办法是在make参数后面添加 DISABLE_HOTSPOT_OS_VERSION_CHECK=OK 即可

 

6. ERROR: error: "__LEAF" redefined [-Werror]

这个是已知的bug(http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/a6eef545f1a2), 在hopspot下打入该patch(http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/raw-rev/a6eef545f1a2)即可

7. ERROR error: converting ‘false’ to pointer type ‘methodOop’ [-Werror=conversion-null]

这个的问题是把 false 转换成 NULL的时候出错了
同样在hotspot下 打入该 patch(http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/raw-rev/f457154eee8b)

 

8. ERROR gcc: error: unrecognized command line option '-mimpure-text'
这个-mimpure-text是gcc给Solaris的编译选项,所以注释掉即可
文件在./jdk/make/common/shared/Compiler-gcc.gmk +70

9. ERROR undefined reference to 'snd_pcm_format_**'

folow this link Build openjdk in Ubuntu 11.10

 

在jdk/make/javax/sound/jsoundalsa/Makefile 里面


 

编译成功!


 

参考资料:

编译:http://hg.openjdk.java.net/jdk7/build/raw-file/tip/README-builds.html

http://hadwinzhy.gitcafe.com/blog/2013/01/21/compile-jdk/

http://wendal.net/420.html
http://thebye85.iteye.com/blog/1545311

http://rednaxelafx.iteye.com/blog/875957


关于为啥要自己编译jdk:http://rednaxelafx.iteye.com/blog/1549577

  • 大小: 89.2 KB
  • 大小: 23.9 KB
  • 大小: 39.1 KB
分享到:
评论
4 楼 zgw06629 2016-03-06  
有些错误这儿没有 如
symbol JVM_SetNativeThreadName, version SUNWprivate_1.1 not defined in file libjvm.so with link time reference

可以看
http://blog.163.com/xiangfei209@126/blog/static/986956742014317802435/
3 楼 zgw06629 2016-03-06  
Thanks!
2 楼 xiaor186 2015-01-27  


环境:Ubuntu 10.10, OpenJDK 6
1. 下载OpenJDK源码
2. 下载依赖性
sudo aptitude build-dep openjdk-6
3. 安装openjdk-6-jdk, libmotif-dev
sudo aptitude install openjdk-6-jdk libmotif-dev
4. 设置环境变量
export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
5. Build
make all ALLOW_DOWNLOADS=true
如果不加ALLOW_DOWNLOAD=true, 会报Cannot find source for project jaxp这样的错误。
1 楼 JavaOrNot 2014-08-17  
Very Good!!

相关推荐

Global site tag (gtag.js) - Google Analytics