参考http://happyenjoylife.iteye.com/blog/858147的帖子,成功编码出openjdk7。我的系统是xubuntu12.10。记录下错误解决方法。
1. 安装mercurial Mercurial是一个版本管理工具。 sudo apt-get install mercurial 安装mercurial的扩展,添加fclone在支持 hg clone http://bitbucket.org/pmezard/hgforest-crew 将以下内容添加到$HOME/.hgrc文件中,如果没有则自己创建一个: [extensions] forest=/home/daren/hgforest-crew/forest.py fetch= 2. 下载jdk7源码 hg fclone http://hg.openjdk.java.net/jdk7/jdk7 3. 安装gcc、g++、make等 sudo apt-get install build-essential 4. 安装XRender sudo apt-get install libxrender-dev sudo apt-get install xorg-dev 5. 安装alsa sudo apt-get install libasound2-dev 6. Cups sudo apt-get install libcups2-dev 7. 安装jdk6 直接去软件中心搜索下jdk6安装 8. 安装ant 设置ANT_HOME 9. 安装findbugs
编译
export ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk-amd64/
export ALT_JDK_IMPORT_PATH=/usr/lib/jvm/java-6-openjdk-amd64/
#设置JAXWS、JAXP、CORBA不编译
make DEBUG_NAME=all_fastdebug BUILD_JAXWS=false BUILD_JAXP=false BUILD_CORBA=false
遇到的问题:
1、"*** This OS is not supported:" `uname -a`; exit 1;
解决:
jdk限制了编译的liniux内核版本,修改文件/home/thebye85/jdk7/hotspot/make/linux/Makefile
查看当前的内核版本:$ uname -r
在这行最后加上当前的内核版本3.2%,如下:
SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7% 3.2%
2、/home/thebye85/jdk7/hotspot/src/share/vm/runtime/interfaceSupport.hpp:430:0: 错误: “__LEAF”重定义 [-Werror]
/usr/include/x86_64-linux-gnu/sys/cdefs.h:44:0: 附注: 这是先前定义的位置
cc1plus: all warnings being treated as errors
解决:
修改/usr/include/x86_64-linux-gnu/sys/cdefs.h,将__LEAF换个名字,如修改为__LEAF_A
3、collect2: ld 返回 1
make[5]: *** [/home/thebye85/jdk7/build/linux-amd64/lib/amd64/libjsoundalsa.so] 错误 1
make[5]:正在离开目录 `/home/thebye85/jdk7/jdk/make/javax/sound/jsoundalsa'
make[4]: *** [build] 错误 1
make[4]:正在离开目录 `/home/thebye85/jdk7/jdk/make/javax/sound'
make[3]: *** [all] 错误 1
make[3]:正在离开目录 `/home/thebye85/jdk7/jdk/make/javax'
make[2]: *** [all] 错误 1
make[2]:正在离开目录 `/home/thebye85/jdk7/jdk/make'
make[1]: *** [jdk-build] 错误 2
make[1]:正在离开目录 `/home/thebye85/jdk7'
make: *** [build_product_image] 错误 2
解决:
ln -s /home/thebye85/jdk7/build/linux-amd64/lib/amd64/libjsound.so /home/thebye85/jdk7/build/linux-amd64/lib/amd64/libjsoundalsa.so