7 linux 编译zlib
2016-10-04 11:07:39 alpha_xiao 阅读数 1085

首先如果linux的没有gcc命令;需要安装一下(可以用yum安装开发者工具):

yum groupinstall "Development Tools"

1.vim hello.c


2.gcc -o hello hello.c 





gcc的简易用法(参考鸟哥私房菜基础第三版)


2015-08-17 11:18:46 fu_zk 阅读数 3176
uname -r #-> 3.10.0-123.el7.x86_64
 
yum install kernel-devel kernel-headers
cd /tmp
wget http://vault.centos.org/7.0.1406/os/Source/SPackages/kernel-3.10.0-123.el7.src.rpm
rpm -ihv kernel-3.10.0-123.el7.src.rpm
cd ~/rpmbuild/SOURCES
tar Jxvf linux-3.10.0-123.el7.tar.xz -C /usr/src/kernels/
cd /usr/src/kernels/
mv $(uname -r) $(uname -r)-old
mv linux-3.10.0-123.el7 $(uname -r)
cd $(uname -r)
make mrproper
cp ../$(uname -r)-old/Module.symvers ./
cp /boot/config-$(uname -r) ./.config
make oldconfig
make prepare
make scripts
make CONFIG_BLK_DEV_NBD=m M=drivers/block
cp drivers/block/nbd.ko /lib/modules/$(uname -r)/kernel/drivers/block/
depmod -a
2015-08-05 17:47:28 pandajava 阅读数 2247

----------------------------------------CentOS-6.6-x86_64-bin-DVD1.iso      mysql-5.6.15------------------------------------

转载自:http://blog.csdn.net/wendi_0506/article/details/39478369

一、编译安装MySQL前的准备工作

安装编译源码所需的工具和库

  1. yum install gcc gcc-c++ ncurses-devel perl  

安装cmake,从http://www.cmake.org下载源码并编译安装

  1. wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz   
  2. tar -xzvf cmake-2.8.10.2.tar.gz   
  3. cd cmake-2.8.10.2   
  4. ./bootstrap ; make ; make install   
  5. cd ~  

二、设置MySQL用户和组

新增mysql用户组

  1. groupadd mysql  
新增mysql用户
  1. useradd -r -g mysql mysql  

三、新建MySQL所需要的目录

新建mysql安装目录

  1. mkdir -p /usr/local/mysql  
新建mysql数据库数据文件目录
  1. mkdir -p /data/mysqldb  

四、下载MySQL源码包并解压

从http://dev.mysql.com/downloads/mysql/直接下载源码,解压mysql-5.6.16.tar.gz(http://www.quseqi.com/这个网站就是用的5.6.16版本)

  1. wget http://www.kakapart.com/files/mysql-5.6.16.tar.gz  
  2. tar -zxv -f mysql-5.6.16.tar.gz  
  3. cd mysql-5.6.16  

五、编译安装MySQL

从mysql5.5起,mysql源码安装开始使用cmake了,设置源码编译配置脚本。设置编译参数:

-DCMAKE_INSTALL_PREFIX=dir_name 设置mysql安装目录
-DMYSQL_UNIX_ADDR=file_name 设置监听套接字路径,这必须是一个绝对路径名。默认为/tmp/mysql.sock
-DDEFAULT_CHARSET=charset_name 设置服务器的字符集。
缺省情况下,MySQL使用latin1的(CP1252西欧)字符集。cmake/character_sets.cmake文件包含允许的字符集名称列表。
-DDEFAULT_COLLATION=collation_name 设置服务器的排序规则。
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1
存储引擎选项:

MyISAM,MERGE,MEMORY,和CSV引擎是默认编译到服务器中,并不需要明确地安装。

静态编译一个存储引擎到服务器,使用-DWITH_engine_STORAGE_ENGINE= 1

可用的存储引擎值有:ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), 和PERFSCHEMA (Performance Schema)
-DMYSQL_DATADIR=dir_name 设置mysql数据库文件目录
-DMYSQL_TCP_PORT=port_num 设置mysql服务器监听端口,默认为3306
-DENABLE_DOWNLOADS=bool 是否要下载可选的文件。例如,启用此选项(设置为1),cmake将下载谷歌所使用的测试套件运行单元测试。
















  1. cmake \   
  2. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \   
  3. -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \   
  4. -DDEFAULT_CHARSET=utf8 \   
  5. -DDEFAULT_COLLATION=utf8_general_ci \   
  6. -DWITH_INNOBASE_STORAGE_ENGINE=1 \   
  7. -DWITH_ARCHIVE_STORAGE_ENGINE=1 \   
  8. -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \   
  9. -DMYSQL_DATADIR=/data/mysqldb \   
  10. -DMYSQL_TCP_PORT=3306 \   
  11. -DENABLE_DOWNLOADS=1  
注:重新运行配置,需要删除CMakeCache.txt文件
  1. rm CMakeCache.txt  
编译源码
  1. make  
安装
  1. make install  

六、修改mysql目录所有者和组

修改mysql安装目录

  1. cd /usr/local/mysql   
  2. chown -R mysql:mysql .  
修改mysql数据库文件目录
  1. cd /data/mysqldb  
  2. chown -R mysql:mysql .  

七、初始化mysql数据库

  1. cd /usr/local/mysql   
  2. scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb  

八、复制mysql服务启动配置文件

  1. cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf  
注:如果/etc/my.cnf文件存在,则覆盖。

九、复制mysql服务启动脚本及加入PATH路径

  1. cp support-files/mysql.server /etc/init.d/mysqld   
  2.   
  3. vim /etc/profile   
  4.   
  5. export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH  
  6.   
  7. source /etc/profile    

十、启动mysql服务并加入开机自启动(可选这个步骤,以后可以自己启动的)

service mysqld start 
chkconfig --level 35 mysqld on

十一、检查mysql服务是否启动

  1. netstat -tulnp | grep 3306   
  2. mysql -u root -p   
密码为空,如果能登陆上,则安装成功。

十二、修改MySQL用户root的密码

  1. mysqladmin -u root password '123456'   
注:也可运行安全设置脚本,修改MySQL用户root的密码,同时可禁止root远程连接,移除test数据库和匿名用户。
  1. /usr/local/mysql/bin/mysql_secure_installation  

十三、可能会出现的错误

  1. 问题:   
  2. Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com.pid).   
  3. 解决:   
  4. 修改/etc/my.cnf 中datadir,指向正确的mysql数据库文件目录  
  1. 问题:   
  2. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)   
  3. 解决:   
  4. 新建一个链接或在mysql中加入-S参数,直接指出mysql.sock位置。   
  5. ln -s /usr/local/mysql/data/mysql.sock /tmp/mysql.sock   
  6.   
  7. /usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/data/mysql.sock  
  1. MySQL问题解决:-bash:mysql:command not found  
  2. 因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,  
  3. 系统在/usr/bin下面查此命令,所以找不到了   
  4.    解决办法是:  
  5.  ln -s /usr/local/mysql/bin/mysql /usr/bin 做个链接即可  

第五条编译出错。用下面这个
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysqldb \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci


===========================================================================================

自己实践 [安装成功]:

1. 
由于在使用cmake的时候需要编译器,同时gcc也是需要的所以,建议搭建好yum源
yum install -y cmake  gcc*

2.
验证cmake安装成功
[pjm001@PjmLinuixCentOs6 mysql-5.6.15]$ cmake -version
cmake version 2.8.12.2

3.
进入到mysql解压后的根目录
cd  /home/pjm001/softOrignFile/mysql-5.6.15
否则报错:
CMake Error: The source directory "/home/pjm001/softOrignFile" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
查找CMakeLists.txt这个文件是在mysql-5.6.15的根目录下。

4.
root执行:
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysqldb \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

5.
报错:
-- Check size of wint_t - done
-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:85 (MESSAGE):
  Curses library not found.  Please install appropriate package,


      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:128 (FIND_CURSES)
  cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:401 (MYSQL_CHECK_EDITLINE)


6.
删掉CMakeCache.txt这个文件

7.
还是报错
百度得:http://zhidao.baidu.com/link?url=lL4VPqO6M6AgkVpVQucGfisfhrdDetZws57w8cpaHC_YIPyWK-l2VuE3MZtQ6WSXf5sYj8olSMcyuC-CTjHh4_


先安装 ncurses-devel 包
yum install ncurses-devel
再删除刚才编译生成的 CMakeCache.txt 文件
rm CMakeCache.txt
再次执行一次cmake ... 
一般都可以顺利安装的。

8.
再次执行
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysqldb \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

9.
编译时间比较久啊,编译完成自动安装。
make  &&  make install

&&
方式:command1 && command2
如果command1执行成功,则执行command2

||
方式:command1 || command2
如果command1执行失败,则执行command2

10.
groupadd mysql  
useradd -r -g mysql mysql  

11.
cd /data/mysqldb
chown -R mysql:mysql .

12.
初始化mysql数据库
cd /usr/local/mysql   
scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb  

13.
复制mysql服务启动配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf  
注:如果/etc/my.cnf文件存在,则覆盖。

14.
复制mysql服务启动脚本及加入PATH路径
cp support-files/mysql.server /etc/init.d/mysqld    
vim /etc/profile   
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH    
export PATH  
source /etc/profile    

15.
启动mysql服务并加入开机自启动(可选这个步骤,以后可以自己启动的)
service mysqld start 
chkconfig --level 35 mysqld on

16.
检查mysql服务是否启动
netstat -tulnp | grep 3306   
mysql -u root -p   
密码为空,如果能登陆上,则安装成功。

17.
修改MySQL用户root的密码
mysqladmin -u root password '123456'  


18.

允许root远程登录:

打开MySQL数据库远程访问的权限   http://www.cnblogs.com/ycsfwhh/archive/2012/08/07/2626597.html

===========================================================================================

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ 设置mysql安装目录
-DMYSQL_DATADIR=/data/mysqldb \ 设置mysql数据库文件目录
-DSYSCONFDIR=/etc \ 配置文件(my.cnf)目录
-DWITH_MYISAM_STORAGE_ENGINE=1 \ 支持MyIASM引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ 支持INNOBASE引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 \ 支持Memory引擎
-DWITH_READLINE=1 \ 快捷键功能(没用过...)
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \     设置监听套接字路径,这必须是一个绝对路径名。默认为/tmp/mysql.sock
-DMYSQL_TCP_PORT=3306 \         设置mysql服务器监听端口,默认为3306
-DENABLED_LOCAL_INFILE=1 \ 允许从本地导入数据
-DWITH_PARTITION_STORAGE_ENGINE=1 \ 安装支持数据库分区
-DEXTRA_CHARSETS=all \ 安装所有的字符集
-DDEFAULT_CHARSET=utf8 \ 默认字符
-DDEFAULT_COLLATION=utf8_general_ci 设置服务器的排序规则。


参考链接:

MySQL cmake编译时这些参数是什么意思?

http://segmentfault.com/q/1010000000611819

参考官方文档
http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html

一般用到的参数

# -DCMAKE_INSTALL_PREFIX=/usr/local/mysql          \    #安装路径
# -DMYSQL_DATADIR=/usr/local/mysql/data            \    #数据文件存放位置
# -DSYSCONFDIR=/etc                                \    #my.cnf路径
# -DWITH_MYISAM_STORAGE_ENGINE=1                   \    #支持MyIASM引擎
# -DWITH_INNOBASE_STORAGE_ENGINE=1                 \    #支持InnoDB引擎
# -DWITH_MEMORY_STORAGE_ENGINE=1                   \    #支持Memory引擎
# -DWITH_READLINE=1                                \    #快捷键功能(我没用过)
# -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock               \    #连接数据库socket路径
# -DMYSQL_TCP_PORT=3306                            \    #端口
# -DENABLED_LOCAL_INFILE=1                         \    #允许从本地导入数据
# -DWITH_PARTITION_STORAGE_ENGINE=1                \    #安装支持数据库分区
# -DEXTRA_CHARSETS=all                             \    #安装所有的字符集
# -DDEFAULT_CHARSET=utf8                           \    #默认字符


2016-12-11 10:15:33 zhou0842 阅读数 90


        在 linux 下编译程序时需要根据不同的开发语言选择对应的编译器,如果使用的是纯 C 语言,则使用 gcc 编

译器,默认链接的是 C 库。如果使用的 C++ 语言写的程序,可以使用 g++ 去编译,编译器会去链接 C++ 库。如

果想要使用 gcc 去编译 c++ 程序,需要指定链接库,在 gcc 后面添加 -lstdc++ 选项即可。链接时会去找到 

/usr/lib/libstdc++ 

    

2018-05-01 02:35:00 weixin_30262255 阅读数 1

今天学习《深入理解Java虚拟机:JVM高级特性与最佳实践》一书,并动手在Linux系统上编译OpenJDK 7,初次搞不太顺利,特记录下编译操作细节。

一、前期准备

约定:工具默认安装目录是/usr/local/,若有源码,则源码存放在/usr/local/src/目录下,笔者用到的工具已打包上传到百度云:https://pan.baidu.com/s/1WhsQHJvduK75EBE8lQqq9g

  1、编译需要的相关工具

    yum -y install gcc gcc-c++ alsa-lib alsa-lib-devel libXrender libXrender-devel libXi-devel libXt-devel libXtst-devel cups cups-devel

2、FreeType

笔者使用的是freetype-2.4.0.tar.gz,下载地址:https://sourceforge.net/projects/freetype/files/freetype2/2.4.0/

tar -zxvf freetype-2.4.0.tar.gz    # 解压

cd freetype-2.4.0

./configure && make && make install    # 编译安装

3、Apache Ant

笔者使用的是apache-ant-1.9.7-bin.tar.gz,下载地址:https://archive.apache.org/dist/ant/binaries/

tar -zxvf apache-ant-1.9.7-bin.tar.gz  # 解压

mv apache-ant-1.9.7 /usr/local/

ln -s /usr/local/apache-ant-1.9.7/bin/ant /usr/bin/ant  # 软链接到bin

4、BootstrapJDK

笔者使用的是jdk-6u45-linux-x64,因为源码更多是使用Java写的,因此需要使用一个可用的JDK去编译(详见深入理解Java虚拟机第一章),OpenJDK解压目录下有个README-builds.html<OpenJDK Build README>,建议详看一遍,文档说使用JDK 6

下载jdk-6u45-linux-x64.bin,下载地址:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html

./jdk-6u45-linux-x64.bin    # 解压

mv jdk1.6.0_45 /usr/local/  # 移动目录

  5、OpenJDK

下载OpenJDK 7,地址:http://download.java.net/openjdk/jdk7/promoted/b147/openjdk-7-fcs-src-b147-27_jun_2011.zip,文件校验码:http://download.java.net/openjdk/jdk7/promoted/b147/openjdk-7-fcs-src-b147-27_jun_2011.md5

wget http://download.java.net/openjdk/jdk7/promoted/b147/openjdk-7-fcs-src-b147-27_jun_2011.zip   # 下载

unzip openjdk-7-fcs-src-b147-27_jun_2011.zip   # 解压

mv openjdk openjdk7  # 更改目录名

mkdir /usr/local/openjdk7  # 创建编译结果存放目录

二、配置环境变量

vim /etc/profile  # 在末尾加入以下内容注意各个目录Path

# openjdk 7 build
export ANT_HOME=/usr/local/apache-ant-1.9.7
export ALT_FREETYPE_HEADERS_PATH=/usr/local/include/freetype2
export ALT_FREETYPE_LIB_PATH=/usr/local/lib
export ALT_DROPS_DIR=/usr/local/src/openjdk7/drop
export ALT_BOOTDIR=/usr/local/jdk1.6.0_45
export ALT_JDK_IMPORT_PATH=/usr/local/jdk1.6.0_45
export ALT_OUTPUTDIR=/usr/local/openjdk7
export LANG=C  # default: en_US.UTF-8
export HOTSPOT_BUILD_JOBS=8
export ALT_PARALLEL_COMPILE_JOBS=8
export SKIP_COMPARE_IMAGES=true
export USE_PRECOMPILED_HEADER=true
export ALLOW_DOWNLOADS=true
export SKIP_DEBUG_BUILD=false
export SKIP_FASTDEBUG_BUILD=true
export DEBUG_NAME=debug
unset JAVA_HOME
unset CLASSPATH

  :wq  # 写入磁盘

  source /etc/profile  # 刷新环境变量配置使之生效,建议echo下几个配置项确认生效,例:echo $LANG

  cd openjdk7  # 进入OpenJDK解压目录

  make sanity   # 检查之前的配置是否正确,若无错误(Sanity check passed.)则OK,下面是笔者的执行结果宫参考

[root@dsp-centos-1-6_9 openjdk7]# make sanity
( cd  ./jdk/make && \
          make sanity HOTSPOT_IMPORT_CHECK=false JDK_TOPDIR=/usr/local/src/openjdk7/jdk JDK_MAKE_SHARED_DIR=/usr/local/src/openjdk7/jdk/make/common/shared EXTERNALSANITYCONTROL=true SOURCE_LANGUAGE_VERSION=7 TARGET_CLASS_VERSION=7 MILESTONE=internal BUILD_NUMBER=b00 JDK_BUILD_NUMBER=b00 FULL_VERSION=1.7.0-internal-debug-root_2018_05_01_00_10-b00 PREVIOUS_JDK_VERSION=1.6.0 JDK_VERSION=1.7.0 JDK_MKTG_VERSION=7 JDK_MAJOR_VERSION=1 JDK_MINOR_VERSION=7 JDK_MICRO_VERSION=0 PREVIOUS_MAJOR_VERSION=1 PREVIOUS_MINOR_VERSION=6 PREVIOUS_MICRO_VERSION=0 ARCH_DATA_MODEL=64 VARIANT=DBG DEBUG_CLASSFILES=true COOKED_BUILD_NUMBER=0 ANT_HOME="/usr/local/apache-ant-1.9.7" ALT_OUTPUTDIR=/usr/local/openjdk7 ALT_LANGTOOLS_DIST=/usr/local/openjdk7/langtools/dist ALT_CORBA_DIST=/usr/local/openjdk7/corba/dist ALT_JAXP_DIST=/usr/local/openjdk7/jaxp/dist ALT_JAXWS_DIST=/usr/local/openjdk7/jaxws/dist ALT_HOTSPOT_IMPORT_PATH=/usr/local/openjdk7/hotspot/import BUILD_HOTSPOT=true ; )
make[1]: Entering directory `/usr/local/src/openjdk7/jdk/make'
make[1]: Leaving directory `/usr/local/src/openjdk7/jdk/make'

Build Machine Information:
   build machine = dsp-centos-3-6_9

Build Directory Structure:
   CWD = /usr/local/src/openjdk7
   TOPDIR = .
   LANGTOOLS_TOPDIR = ./langtools
   JAXP_TOPDIR = ./jaxp
   JAXWS_TOPDIR = ./jaxws
   CORBA_TOPDIR = ./corba
   HOTSPOT_TOPDIR = ./hotspot
   JDK_TOPDIR = ./jdk

Build Directives:
   BUILD_LANGTOOLS = true 
   BUILD_JAXP = true 
   BUILD_JAXWS = true 
   BUILD_CORBA = true 
   BUILD_HOTSPOT = true 
   BUILD_JDK    = true 
   DEBUG_CLASSFILES =  
   DEBUG_BINARIES =  

Hotspot Settings: 
      HOTSPOT_BUILD_JOBS  = 8 
      HOTSPOT_OUTPUTDIR   = /usr/local/openjdk7/hotspot/outputdir 
      HOTSPOT_EXPORT_PATH = /usr/local/openjdk7/hotspot/import 
 



Bootstrap Settings:
  BOOTDIR = /usr/local/jdk1.6.0_45
    ALT_BOOTDIR = /usr/local/jdk1.6.0_45
  BOOT_VER = 1.6.0 [requires at least 1.6]
  OUTPUTDIR = /usr/local/openjdk7
    ALT_OUTPUTDIR = /usr/local/openjdk7
  ABS_OUTPUTDIR = /usr/local/openjdk7
 
Build Tool Settings:
  SLASH_JAVA = /NOT-SET
    ALT_SLASH_JAVA = 
  VARIANT = DBG
  JDK_DEVTOOLS_DIR = /NOT-SET/devtools
    ALT_JDK_DEVTOOLS_DIR = 
  ANT_HOME = /usr/local/apache-ant-1.9.7
  UNIXCOMMAND_PATH = /bin/
    ALT_UNIXCOMMAND_PATH = 
  COMPILER_PATH = /usr/bin/
    ALT_COMPILER_PATH = 
  DEVTOOLS_PATH = /usr/bin/
    ALT_DEVTOOLS_PATH = 
  UNIXCCS_PATH = /usr/ccs/bin/
    ALT_UNIXCCS_PATH = 
  USRBIN_PATH = /usr/bin/
    ALT_USRBIN_PATH = 
  COMPILER_NAME = GCC4
  COMPILER_VERSION = GCC4
  CC_VER = 4.4.7 [requires at least 4.3.0]
  ZIP_VER = 3.0 [requires at least 2.2]
  UNZIP_VER = 6.00 [requires at least 5.12]
  ANT_VER = 1.9.7 [requires at least 1.7.1]
  TEMPDIR = /usr/local/openjdk7/tmp
 
Build Directives:
  OPENJDK = true
  USE_HOTSPOT_INTERPRETER_MODE = 
  PEDANTIC = 
  DEV_ONLY = 
  NO_DOCS = 
  NO_IMAGES = 
  TOOLS_ONLY = 
  INSANE = 
  COMPILE_APPROACH = parallel
  PARALLEL_COMPILE_JOBS = 8
    ALT_PARALLEL_COMPILE_JOBS = 8
  FASTDEBUG = 
  COMPILER_WARNINGS_FATAL = false
  COMPILER_WARNING_LEVEL = 
  SHOW_ALL_WARNINGS = 
  INCREMENTAL_BUILD = false
  CC_HIGHEST_OPT = 
  CC_HIGHER_OPT = 
  CC_LOWER_OPT = 
  CXXFLAGS =  -g -fPIC -DCC_NOEX -W -Wall  -Wno-unused -Wno-parentheses -fno-omit-frame-pointer -D_LITTLE_ENDIAN  
  CFLAGS =  -g   -fno-strict-aliasing -fPIC -W -Wall  -Wno-unused -Wno-parentheses -pipe -fno-omit-frame-pointer -D_LITTLE_ENDIAN  
  BOOT_JAVA_CMD = /usr/local/jdk1.6.0_45/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m
  BOOT_JAVAC_CMD = /usr/local/jdk1.6.0_45/bin/javac  -J-XX:ThreadStackSize=1536 -J-XX:-PrintVMOptions -J-XX:+UnlockDiagnosticVMOptions -J-XX:-LogVMOutput -J-Xmx512m -J-Xms512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -encoding ascii -source 6 -target 6 -XDignore.symbol.file=true
  BOOT_JAR_CMD = /usr/local/jdk1.6.0_45/bin/jar
  BOOT_JARSIGNER_CMD = /usr/local/jdk1.6.0_45/bin/jarsigner
  JAVAC_CMD = /usr/local/jdk1.6.0_45/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m -Xbootclasspath/p:/usr/local/openjdk7/langtools/dist/bootstrap/lib/javac.jar -jar /usr/local/openjdk7/langtools/dist/bootstrap/lib/javac.jar  -g -source 7 -target 7 -encoding ascii -Xbootclasspath:/usr/local/openjdk7/classes 
  JAVAH_CMD = /usr/local/jdk1.6.0_45/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m -Xbootclasspath/p:/usr/local/openjdk7/langtools/dist/bootstrap/lib/javah.jar:/usr/local/openjdk7/langtools/dist/bootstrap/lib/javac.jar -jar /usr/local/openjdk7/langtools/dist/bootstrap/lib/javah.jar -bootclasspath /usr/local/openjdk7/classes
  JAVADOC_CMD = /usr/local/jdk1.6.0_45/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Xmx512m -Xms512m -XX:PermSize=32m -XX:MaxPermSize=160m -Xbootclasspath/p:/usr/local/openjdk7/langtools/dist/bootstrap/lib/javadoc.jar:/usr/local/openjdk7/langtools/dist/bootstrap/lib/javac.jar:/usr/local/openjdk7/langtools/dist/bootstrap/lib/doclets.jar -jar /usr/local/openjdk7/langtools/dist/bootstrap/lib/javadoc.jar -bootclasspath /usr/local/openjdk7/classes
 
Build Platform Settings:
  USER = root
  PLATFORM = linux
  ARCH = amd64
  LIBARCH = amd64
  ARCH_FAMILY = amd64
  ARCH_DATA_MODEL = 64
  ARCHPROP = amd64
  ALSA_VERSION = 1.1.0
  OS_VERSION = 2.6.32-696.16.1.el6.x86_64 [requires at least 2.6]
  OS_VARIANT_NAME = RedHat
  OS_VARIANT_VERSION = 
  MB_OF_MEMORY = 1861
 
GNU Make Settings:
  MAKE = make
  MAKE_VER = 3.81 [requires at least 3.81]
  MAKECMDGOALS = sanity
  MAKEFLAGS = w
  SHELL = /bin/sh
 
Target Build Versions:
  JDK_VERSION = 1.7.0
  MILESTONE = internal
  RELEASE = 1.7.0-internal-debug
  FULL_VERSION = 1.7.0-internal-debug-root_2018_05_01_00_10-b00
  BUILD_NUMBER = b00
 
External File/Binary Locations:
  USRJDKINSTANCES_PATH = /opt/java
  BUILD_JDK_IMPORT_PATH = /NOT-SET/re/jdk/1.7.0/promoted/latest/binaries
    ALT_BUILD_JDK_IMPORT_PATH = 
  JDK_IMPORT_PATH = /usr/local/jdk1.6.0_45
    ALT_JDK_IMPORT_PATH = /usr/local/jdk1.6.0_45
  LANGTOOLS_DIST = /usr/local/openjdk7/langtools/dist
    ALT_LANGTOOLS_DIST = /usr/local/openjdk7/langtools/dist
  CORBA_DIST = /usr/local/openjdk7/corba/dist
    ALT_CORBA_DIST = /usr/local/openjdk7/corba/dist
  JAXP_DIST = /usr/local/openjdk7/jaxp/dist
    ALT_JAXP_DIST = /usr/local/openjdk7/jaxp/dist
  JAXWS_DIST = /usr/local/openjdk7/jaxws/dist
    ALT_JAXWS_DIST = /usr/local/openjdk7/jaxws/dist
  HOTSPOT_DOCS_IMPORT_PATH = /usr/local/openjdk7/hotspot/import/docs
    ALT_HOTSPOT_DOCS_IMPORT_PATH = 
  HOTSPOT_IMPORT_PATH = /usr/local/openjdk7/hotspot/import
    ALT_HOTSPOT_IMPORT_PATH = /usr/local/openjdk7/hotspot/import
  HOTSPOT_SERVER_PATH = /usr/local/openjdk7/hotspot/import/jre/lib/amd64/server
    ALT_HOTSPOT_SERVER_PATH = 
  CACERTS_FILE = ./../src/share/lib/security/cacerts
    ALT_CACERTS_FILE = 
  CUPS_HEADERS_PATH = /usr/include
    ALT_CUPS_HEADERS_PATH = 
 
OpenJDK-specific settings:
  FREETYPE_HEADERS_PATH = /usr/local/include/freetype2
    ALT_FREETYPE_HEADERS_PATH = /usr/local/include/freetype2
  FREETYPE_LIB_PATH = /usr/local/lib
    ALT_FREETYPE_LIB_PATH = /usr/local/lib
 
Previous JDK Settings:
  PREVIOUS_RELEASE_PATH = USING-PREVIOUS_RELEASE_IMAGE
    ALT_PREVIOUS_RELEASE_PATH = 
  PREVIOUS_JDK_VERSION = 1.6.0
    ALT_PREVIOUS_JDK_VERSION = 
  PREVIOUS_JDK_FILE = 
    ALT_PREVIOUS_JDK_FILE = 
  PREVIOUS_JRE_FILE = 
    ALT_PREVIOUS_JRE_FILE = 
  PREVIOUS_RELEASE_IMAGE = /usr/local/jdk1.6.0_45
    ALT_PREVIOUS_RELEASE_IMAGE = 


Sanity check passed.
View Code

 三、编译操作

   make 2>&1 | tee $ALT_OUTPUTDIR/build.log  # 编译,标准错误输出stderr重定向到标准输出stdout,将编译过程数据重定向到文件保存。

  若编译失败,重新编译前先执行:make clean

  若编译成功,提示信息如下:

-- Build times ----------
Target debug_build
Start 2018-04-30 23:30:30
End 2018-04-30 23:45:05
00:01:45 corba
00:03:32 hotspot
00:00:18 jaxp
00:00:24 jaxws
00:08:05 jdk
00:00:31 langtools
00:14:35 TOTAL
-------------------------

四、验证

  进入/usr/local/openjdk7/bin(即$ALT_OUTPUTDIR/bin)目录,执行:./java -version

[root@dsp-centos-1-6_9 bin]# ./java -version
openjdk version "1.7.0-internal-debug"
OpenJDK Runtime Environment (build 1.7.0-internal-debug-root_2018_04_30_20_26-b00)
OpenJDK 64-Bit Server VM (build 21.0-b17-jvmg, mixed mode)

  验证虚拟机

---------------------------------------------------------------------------------
# 将env.sh中的环境变量单独拎出来执行下,笔者直接执行env.sh没效果
# export JAVA_HOME=/usr/local/jdk1.6.0_45
# export LD_LIBRARY_PATH=.:${JAVA_HOME}/jre/lib/amd64/native_threads:${JAVA_HOME}/jre/lib/amd64:
# export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/jre/lib/i18n.jar
# export HOTSPOT_BUILD_USER="root in hotspot"

[root@dsp-centos-1-6_9 jvmg]# export JAVA_HOME=/usr/local/jdk1.6.0_45
[root@dsp-centos-1-6_9 jvmg]# echo $JAVA_HOME # 确认下是否符合预期
/usr/local/jdk1.6.0_45
[root@dsp-centos-1-6_9 jvmg]# export LD_LIBRARY_PATH=.:${JAVA_HOME}/jre/lib/amd64/native_threads:${JAVA_HOME}/jre/lib/amd64:
[root@dsp-centos-1-6_9 jvmg]# echo $LD_LIBRARY_PATH
.:/usr/local/jdk1.6.0_45/jre/lib/amd64/native_threads:/usr/local/jdk1.6.0_45/jre/lib/amd64:
[root@dsp-centos-1-6_9 jvmg]# export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/jre/lib/i18n.jar
[root@dsp-centos-1-6_9 jvmg]# echo $CLASSPATH
.:/usr/local/jdk1.6.0_45/jre/lib/rt.jar:/usr/local/jdk1.6.0_45/jre/lib/i18n.jar
[root@dsp-centos-1-6_9 jvmg]# export HOTSPOT_BUILD_USER="root in hotspot"
[root@dsp-centos-1-6_9 jvmg]# echo $HOTSPOT_BUILD_USER
root in hotspot
---------------------------------------------------------------------------------
[root@dsp-centos-1-6_9 jvmg]# ./gamma -version
Using java runtime at: /usr/local/jdk1.6.0_45/jre
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
OpenJDK 64-Bit Server VM (build 21.0-b17-jvmg, mixed mode)
---------------------------------------------------------------------------------
[root@dsp-centos-1-6_9 jvmg]# ./test_gamma   # 解八皇后问题
java full version "1.6.0_45-b06"
Using java runtime at: /usr/local/jdk1.6.0_45/jre
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
OpenJDK 64-Bit Server VM (build 21.0-b17-jvmg, mixed mode)

1. A1 B5 C8 D6 E3 F7 G2 H4 
2. A1 B6 C8 D3 E7 F4 G2 H5 
3. A1 B7 C4 D6 E8 F2 G5 H3 
4. A1 B7 C5 D8 E2 F4 G6 H3 
5. A2 B4 C6 D8 E3 F1 G7 H5 
6. A2 B5 C7 D1 E3 F8 G6 H4 
7. A2 B5 C7 D4 E1 F8 G6 H3 
8. A2 B6 C1 D7 E4 F8 G3 H5 
9. A2 B6 C8 D3 E1 F4 G7 H5 
10. A2 B7 C3 D6 E8 F5 G1 H4 
11. A2 B7 C5 D8 E1 F4 G6 H3 
12. A2 B8 C6 D1 E3 F5 G7 H4 
13. A3 B1 C7 D5 E8 F2 G4 H6 
14. A3 B5 C2 D8 E1 F7 G4 H6 
15. A3 B5 C2 D8 E6 F4 G7 H1 
16. A3 B5 C7 D1 E4 F2 G8 H6 
17. A3 B5 C8 D4 E1 F7 G2 H6 
18. A3 B6 C2 D5 E8 F1 G7 H4 
19. A3 B6 C2 D7 E1 F4 G8 H5 
20. A3 B6 C2 D7 E5 F1 G8 H4 
21. A3 B6 C4 D1 E8 F5 G7 H2 
22. A3 B6 C4 D2 E8 F5 G7 H1 
23. A3 B6 C8 D1 E4 F7 G5 H2 
24. A3 B6 C8 D1 E5 F7 G2 H4 
25. A3 B6 C8 D2 E4 F1 G7 H5 
26. A3 B7 C2 D8 E5 F1 G4 H6 
27. A3 B7 C2 D8 E6 F4 G1 H5 
28. A3 B8 C4 D7 E1 F6 G2 H5 
29. A4 B1 C5 D8 E2 F7 G3 H6 
30. A4 B1 C5 D8 E6 F3 G7 H2 
31. A4 B2 C5 D8 E6 F1 G3 H7 
32. A4 B2 C7 D3 E6 F8 G1 H5 
33. A4 B2 C7 D3 E6 F8 G5 H1 
34. A4 B2 C7 D5 E1 F8 G6 H3 
35. A4 B2 C8 D5 E7 F1 G3 H6 
36. A4 B2 C8 D6 E1 F3 G5 H7 
37. A4 B6 C1 D5 E2 F8 G3 H7 
38. A4 B6 C8 D2 E7 F1 G3 H5 
39. A4 B6 C8 D3 E1 F7 G5 H2 
40. A4 B7 C1 D8 E5 F2 G6 H3 
41. A4 B7 C3 D8 E2 F5 G1 H6 
42. A4 B7 C5 D2 E6 F1 G3 H8 
43. A4 B7 C5 D3 E1 F6 G8 H2 
44. A4 B8 C1 D3 E6 F2 G7 H5 
45. A4 B8 C1 D5 E7 F2 G6 H3 
46. A4 B8 C5 D3 E1 F7 G2 H6 
47. A5 B1 C4 D6 E8 F2 G7 H3 
48. A5 B1 C8 D4 E2 F7 G3 H6 
49. A5 B1 C8 D6 E3 F7 G2 H4 
50. A5 B2 C4 D6 E8 F3 G1 H7 
51. A5 B2 C4 D7 E3 F8 G6 H1 
52. A5 B2 C6 D1 E7 F4 G8 H3 
53. A5 B2 C8 D1 E4 F7 G3 H6 
54. A5 B3 C1 D6 E8 F2 G4 H7 
55. A5 B3 C1 D7 E2 F8 G6 H4 
56. A5 B3 C8 D4 E7 F1 G6 H2 
57. A5 B7 C1 D3 E8 F6 G4 H2 
58. A5 B7 C1 D4 E2 F8 G6 H3 
59. A5 B7 C2 D4 E8 F1 G3 H6 
60. A5 B7 C2 D6 E3 F1 G4 H8 
61. A5 B7 C2 D6 E3 F1 G8 H4 
62. A5 B7 C4 D1 E3 F8 G6 H2 
63. A5 B8 C4 D1 E3 F6 G2 H7 
64. A5 B8 C4 D1 E7 F2 G6 H3 
65. A6 B1 C5 D2 E8 F3 G7 H4 
66. A6 B2 C7 D1 E3 F5 G8 H4 
67. A6 B2 C7 D1 E4 F8 G5 H3 
68. A6 B3 C1 D7 E5 F8 G2 H4 
69. A6 B3 C1 D8 E4 F2 G7 H5 
70. A6 B3 C1 D8 E5 F2 G4 H7 
71. A6 B3 C5 D7 E1 F4 G2 H8 
72. A6 B3 C5 D8 E1 F4 G2 H7 
73. A6 B3 C7 D2 E4 F8 G1 H5 
74. A6 B3 C7 D2 E8 F5 G1 H4 
75. A6 B3 C7 D4 E1 F8 G2 H5 
76. A6 B4 C1 D5 E8 F2 G7 H3 
77. A6 B4 C2 D8 E5 F7 G1 H3 
78. A6 B4 C7 D1 E3 F5 G2 H8 
79. A6 B4 C7 D1 E8 F2 G5 H3 
80. A6 B8 C2 D4 E1 F7 G5 H3 
81. A7 B1 C3 D8 E6 F4 G2 H5 
82. A7 B2 C4 D1 E8 F5 G3 H6 
83. A7 B2 C6 D3 E1 F4 G8 H5 
84. A7 B3 C1 D6 E8 F5 G2 H4 
85. A7 B3 C8 D2 E5 F1 G6 H4 
86. A7 B4 C2 D5 E8 F1 G3 H6 
87. A7 B4 C2 D8 E6 F1 G3 H5 
88. A7 B5 C3 D1 E6 F8 G2 H4 
89. A8 B2 C4 D1 E7 F5 G3 H6 
90. A8 B2 C5 D3 E1 F7 G4 H6 
91. A8 B3 C1 D6 E2 F5 G7 H4 
92. A8 B4 C1 D3 E6 F2 G7 H5 
[root@dsp-centos-1-6_9 jvmg]#

 五、笔者碰到的问题

  1、java.lang.RuntimeException: time is more than 10 years from present

    修改jdk/src/share/classes/java/util/CurrencyData.properties,将日期改为十年以内,JDK的Bug。

  108行改为: AZ=AZM;2009-12-31-20-00-00;AZN,接下来的377、439、529、555行类似修改保存,重新编译。

2、/usr/local/openjdk7-debug/jaxws/build/xml_generated/build-drop-jaf_src.xml:96: Redirection detected from https to http. Protocol switch unsafe, not allowed.

  原因是jdk7-jaf-2010_08_19.zip这个包下载不了导致的,解决方案:

将以下三个文件下载后置于OpenJDK解压后根目录下的drop目录下,

并在环境变量中加入配置:export ALT_DROPS_DIR=/usr/local/src/openjdk7/drop # 注意目录Path

jdk7-jaf-2010_08_19.zip,下载地址:https://netix.dl.sourceforge.net/project/jdk7src/input-archives/jdk7-jaf-2010_08_19.zip

jdk7-jaxws2_2_4-b03-2011_05_27.zip,下载地址:http://download.java.net/glassfish/components/jax-ws/openjdk/jdk7/jdk7-jaxws2_2_4-b03-2011_05_27.zip

jaxp145_01.zip,下载地址:http://download.java.net/jaxp/1.4.5/jaxp145_01.zip

以下是操作过程的命令:

mkdir /usr/local/src/openjdk7/drop
export ALT_DROPS_DIR=/usr/local/src/openjdk7/drop
cd /usr/local/src/openjdk7/drop
wget http://download.java.net/jaxp/1.4.5/jaxp145_01.zip
wget https://netix.dl.sourceforge.net/project/jdk7src/input-archives/jdk7-jaf-2010_08_19.zip
wget http://download.java.net/glassfish/components/jax-ws/openjdk/jdk7/jdk7-jaxws2_2_4-b03-2011_05_27.zip

六、参考资料:

  《深入理解Java虚拟机:JVM高级特性与最佳实践》

  [深入理解Java虚拟机]第一章实战 自己编译JDK

  ubuntu13 编译openjdk7的问题并解决

  java-编译openJdk

  openjdk7 源码下载

JDK源码下载

OpenJDK8 Windows编译

转载于:https://www.cnblogs.com/gotodsp/p/8975387.html

没有更多推荐了,返回首页