在redhat与ubuntu上编译jdk常见错误总结

    在redhatubuntu上都搭建过jdk的调试环境,在windows上也曾尝试过没有成功。总的来说在Linux系统下搭建还是要简单得多的。网上有很多的教程,莫枢、周志明等等都是这方面的专家,有很多文章可以参考。这里只总结一下搭建编译环境过程中遇到的问题及其解决办法。

 

1 在redhat 5上编译jdk

1.1 出现错误:configure: error: cannot compute suffix of object files: cannot compile

    需要将mpcgmpmpfr目录加入到环境变量中,在/etc/profile文件末尾加上:export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-3.0.0/lib,注意修改目录,之后运行#source /etc/profile使其生效即可

 

1.2 FreeType version  2.3.0  or higher is required.

    强制卸载了freetype -2.2.1-28.el5_7.2

    rpm –e –nodeps freetype -2.2.1-28.el5_7.2

    应该值之前的freetype版本的影响。

 

1.3 error while loading shared libraries: libmpc.so.2: cannot open shared object file: No such file or directory

    由于已经取消了变量:LD_LIBRARY_PATH,故系统无法自动找到libmpc.so.2,采取了一个变通的方式,建立了一个软链接:

    ln -s /usr/local/mpc-0.8.1/lib/libmpc.so.2 /lib/libmpc.so.2

 

1.4 /usr/local/gcc-4.8.1/libexec/gcc/i686-pc-linux-gnu/4.8.1/cc1plus: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory

    同错误3类似。

 

1.5 /opt/jdkbuild/jdk7/hotspot/src/share/vm/oops/constantPoolOop.cpp:272:39: error: converting 'false' to pointer type 'methodOop' [-Werror=conversion-null]

   if (cpool->cache() == NULL)  return false;  // nothing to load yet

                                                                              ^

    cc1plus: all warnings being treated as errors

    打了一个补丁:

    http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/f457154eee8b

    见说明:

    http://mail.openjdk.java.net/pipermail/hotspot-dev/2012-July/006243.html

 

1.6 /lib/libmpfr.so.1: undefined reference to `__gmp_get_memory_functions'

    见:http://www.mpfr.org/faq.html#undef_ref1

    中的解释,这种错误多见于将GMP 4.1.4升级到更高版本的时候,或者同一台机器上安装了多个版本的GMP。这种错误可能意味着你使用了GMP 4.2.xHeader,但使用了GMP 4.1.4library。所以将原gmp卸载:

    rpm –e –nodeps gmp-4.1.4-10.el5

 

1.7 libgmp.so.3: cannot open shared object file: No such file or directory

    同错误1.3类似。

 

2 在ubuntu 12上编译jdk

    参考资料:

    1. http://www.kaifajie.cn/ubuntu/10272.html

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

 

2.1 ERROR: You seem to not have installed ALSA 0.9.1 or higher

    不需要从ALSA官网下载alsa-devalsa-drive, ubuntu提供包的
  sudo apt-get install libasound2-dev

    

2.2 /usr/bin/gawk: not found

    apt-get install gawk

 

2.3 ERROR: echo "*** This OS is not supported:" 'uname -a'; exit 1;

    注释掉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

    也可以最好的办法是在make参数后面添加 

    DISABLE_HOTSPOT_OS_VERSION_CHECK=OK

 

2.4 /opt/jdkbuild/jdk7/hotspot/src/share/vm/runtime/interfaceSupport.hpp:430:0: error: "__LEAF" redefined [-Werror]

    打补丁:

    http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/a6eef545f1a2

 

2.5 undefined reference to ‘snd_pcm_*’

    见说明:

    http://comments.gmane.org/gmane.comp.java.openjdk.build.devel/5311

    打补丁:

    http://mail.openjdk.java.net/pipermail/build-dev/2011-November/005188.html

    这篇文章里也有说明。

 

2.6 cannot find -lX11

    apt-get install libx11-dev

 

2.7 ../../../src/solaris/native/sun/awt/awt.h:38:27: fatal error: X11/Intrinsic.h: No such file or directory

    apt-get install libxt-dev

 

2.8 X11/extensions/shape.h: No such file or directory

    apt-get install libxtst-dev

    见说明:

    http://www.csdnjava.com/forum.php?mod=viewthread&tid=147509

 

2.9 ../../../src/solaris/native/sun/awt/awt_p.h:51:36: fatal error: X11/extensions/Xrender.h: No such file or directory

    apt-get install libxrender-dev



你可能感兴趣的:(java,jvm,jdk)