官方提供编译文档如下:
CentOS 5.5
After installing CentOS 5.5 you need to make sure you have the following Development bundles installed:
- Development Libraries
- Development Tools
- Java Development
- X Software Development (Including XFree86-devel)
Plus the following packages:
-
cups devel: Cups Development Package
-
alsa devel: Alsa Development Package
-
Xi devel: libXi.so Development Package
The freetype 2.3 packages don't seem to be available, but the freetype 2.3sources can be downloaded, built, and installed easily enough from thefreetype site. Build and installwith something like: bash ./configure make sudo -u root make install
Mercurial packages could not be found easily, but a Google search should findones, and they usually include Python if it's needed.
2 开发者环境搭建
- Yum 安装开发者工具包
yum groupinstall "Development Tools"
yum groupinstall "Development Libraries"
- Yum 安装java 开发者环境
yum install java-1.6.0-openjdk-devel.x86_64
- 安装X Software Development
yum groupinstall "X Window System"
pkg-config --libs x11
执行过程报错 "Package xorg-x11 was not found in the pkg-config search path. Perhaps you should add the directory containing `xorg-x11.pc' to the PKG_CONFIG_PATH environment variable"
先在centos5.5 中搜索 发现并不存在xorg-x11.pc,需要下载 xorg-x11-devel,yum search 方式搜索 yum 本地源中不存在该包,需要编译安装
yum search xorg-x11-devel "Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Warning: No matches found for: xorg-x11-devel No Matches found"
pkg-config --cflags x11
- 编译安装xorg-x11-devel
wget https://www.x.org/releases/individual/proto/xproto-7.0.31.tar.gz
tar -xf xproto-7.0.31.tar.gz
cd xproto-7.0.31
./configure --prefix=/usr/local/xproto-7.0.31
make && make install
echo "/usr/local/xproto-7.0.31/lib" >> /etc/ld.so.conf.d/xproto-7.0.31.conf
ldconfig
pkg-config --libs x11
- 依赖包cups 安装
yum install gcc glibc-headers glibc-devel cups-libs openssl-devel
yum install cups-devel
- 依赖 alsa devel 安装
yum install alsa-lib-devel alsa-utils alsa-lib
rpm -qa | grep alsa
- 安装依赖lib-xi
yum install libXi-devel
yum install libXtst-devel libXt-devel libXrender-devel
rpm -qa | grep libXi-devel
- 安装freetype 2.3
sudo yum install zlib-devel libpng-devel
源码下载地址 https://sourceforge.net/projects/freetype/files/freetype2/2.3.0/
./configure
make
make install
3 System Setup (boot jdk 安装)
Before even attempting to use a system to build the OpenJDK there are some verybasic system setups needed. For all systems:
- Be sure the GNU make utility is version 3.81 or newer, e.g.run "
make -version" - Install a Bootstrap JDK. All OpenJDK builds require access to a previouslyreleased JDK called the bootstrap JDK or boot JDK. The general rule isthat the bootstrap JDK must be an instance of the previous major release ofthe JDK. In addition, there may be a requirement to use a release at orbeyond a particular update level. Building JDK 8 requires use of a version of JDK 7 this is at Update 7or newer. JDK 8 developers should not use JDK 8 as the boot JDK, to ensurethat JDK 8 dependencies are not introduced into the parts of the systemthat are built with JDK 7. The JDK 7 binaries can be downloaded from Oracle's JDK 7 downloadsite.For build performance reasons it is very important that this bootstrap JDKbe made available on the local disk of the machine doing the build. Youshould add its
bindirectory to thePATHenvironment variable. Ifconfigurehas any issues finding this JDK, you may need to use theconfigureoption--with-boot-jdk.
- Ensure that GNU make, the Bootstrap JDK, and the compilers are all in yourPATH environment variable.
- 下载jdk1.8 并解压配置环境变量
wget https://download.oracle.com/otn/java/jdk/8u361-b09/0ae14417abb444ebb02b9815e2103550/jdk-8u361-linux-x64.tar.gz
tar -zxvf jdk-8u361-linux-x64.tar.gz
mv jdk1.8.0_361/ /usr/local/jdk1.8
vim /etc/profile
JAVA_HOME=/usr/local/jdk1.8
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME export PATH
export CLASSPATH
:wq
source /etc/profile
java -versiom
Jdk 安装配置成功
- 配置openjdk8
cd /opt/jdk8u-dev-master/
./configure --with-boot-jdk=/usr/local/jdk1.8 --with-debug-level=slowdebug
检查过程中出现缺少freetype-devel,fontconfig-devel
yum install freetype-devel
yum install fontconfig-devel
wget https://www.samba.org/ftp/ccache/ccache-3.6.tar.gz
tar -zxvf ccache-3.6.tar.gz
cd ccache-3.6
./configure
make
make install
echo 'export PATH="/usr/local/libexec/ccache:$PATH"' >> /etc/profile
source /etc/profile
配置通过
开始 编译安装
make
Vmhoptspot 编译完成,等待最后编译结果。
编译结果 如下:
根据报错信息确定为gcc版本过低导致不支持生成的MAKEFILE 文件中的参数不支持报错,需要升级gcc版本来解决。centos 5.5 默认gcc 版本为4.2
-
编译安装升级gcc 为4.8
- 安装依赖包 libmpc-devel,libgmp-devel,libmpfr-devel
wget https://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
wget https://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.gz
wget https://ftp.gnu.org/gnu/mpfr/mpfr-2.4.2.tar.gz
tar -zxvf mpc-1.0.3.tar.gz
tar -zxvf gmp-4.3.2.tar.gz
tar -zxvf mpfr-2.4.2.tar.gz
cd gmp-4.3.2
./configure
make && make install
cd mpfr-2.4.2
./configured
make && make install
cd mpc-1.0.3
./configure
make && make install
编译过程中发现 glibc 升级依赖高版本gcc ,binutils,高版本gcc 编译依赖glibc ,是个死局,考虑从修改MAKFILE 编译选项入手,在项目目录下全局 搜索 编译选项
grep -rn "unused-parameter" ./
./jdk/src/share/native/sun/awt/libpng/CHANGES:2994: pngvalid and checks with gcc -Wall -Wno-unused-parameter -Wunused.
./jdk/make/lib/NioLibraries.gmk:154: SCTP_WERROR := -Werror -Wno-unused-parameter
按照结果 修改文件./jdk/make/lib/NioLibraries.gmk:154 去掉编译选项 -Wno-unused-parameter
继续make 结果如下:
cc1 error 问题解决
解决 cant find -lXext
ldconfig -p | grep libXext
搜索libXext 路径
sudo ln -s /usr/lib64/libXext.so.6 /usr/lib64/libXext.so
sudo ln -s /usr/lib/libXext.so.6 /usr/lib/libXext.so
继续 make JOBS=8
编译完成 结果如图: