Mac OSX 10.10 Yosemite编译OpenJDK 9

在Mac OSX 10.10系统上编译了下OpenJDK9,以下仅是个人安装记录,供参考。

编译时间:2015-06-13

系统版本:Mac OS X Yosemite 10.10.4

编译OpenJDK版本:JDK 9

相关软件版本:

参考资料:

OpenJDK Home Page

OpenJDK官方编译步骤(下载完源码里面就有README-builds文件)

JDK BUG System(编译遇到问题可以上面搜索)

OpenJDK官网操作系统等要求

编译前期准备:

•大致了解官网系统要求:

https://wiki.openjdk.java.net/display/Build/Supported+Build+Platforms

•源码下载工具安装(此处采用Mercurial工具[OpenJDK的版本管控工具]从官网下载):

安装参考资料:

本机安装脚本:

安装:

$ brew install mercurial

若link失败,则:

$ sudo brew link mercurial

验证版本不低于2.6.3:hg version

安装后版本3.0.2,改为官网下载安装3.4.1了

•安装ccache提高编译速度

$ brew search ccache $ brew install ccache

•安装freetype(编译时需要):

brew install freetype

安装失败,,提示依赖的libpng无法下载。手工安装:

下载libpng最新版1.6.17()并解压:

$ pwd$ cd ./libpng-1.6.17$ ./configure –prefix=/usr/local/libpng-1.6.17$ make$ make install$ cd /usr/local/$ ln -s libpng-1.6.17 /usr/local/libpng$ brew install freetype

•获取JDK源码:

$ mkdir OpenJDK9;cd OpenJDK9$ hg clone $ cd dev$ chmod u+x get_source.sh$ ./get_source.sh

编译配置:

$ bash ./configure –help=short$ bash ./configure –enable-debug –with-target-bits=64…====================================================A new configuration has been successfully created inOpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebugusing configure arguments ‘–enable-debug –with-target-bits=64’.Configuration summary:* Debug level: fastdebug* HS debug level: fastdebug* JDK variant: normal* JVM variants: server* OpenJDK target: OS: macosx, CPU architecture: x86, address length: 64Tools summary:* Boot JDK: java version “1.8.0_45” Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode) (at /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home)* Toolchain: clang (clang/LLVM)* C Compiler: Version Apple LLVM version 6.0 (clang-600.0.41.2) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix (at /usr/bin/clang)* C++ Compiler: Version Apple LLVM version 6.0 (clang-600.0.41.2) (based on LLVM 3.5svn) Target: x86_64-apple-darwin14.4.0 Thread model: posix (at /usr/bin/clang++)Build performance summary:* Cores to use: 2* Memory limit: 4096 MB

编译:

$ make…OpenJDK9/jdk9/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m:387:29: error: sending ‘id<NSApplicationDelegate>’ to parameter of incompatible type ‘id<NSFileManagerDelegate>’ [-Werror] [NSApp setDelegate: applicationDelegate]; ^~~~~~~~~~~~~~~~~~~/System/Library/Frameworks/Foundation.framework/Headers/NSFileManager.h:109:47: note: passing argument to parameter ‘delegate’ here@property (assign) id <NSFileManagerDelegate> delegate NS_AVAILABLE(10_5, 2_0); ^1 error generated.make[3]: *** [OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug/support/native/java.desktop/libosxapp/NSApplicationAWT.o] Error 1make[2]: *** [java.desktop-libs] Error 2make[2]: *** Waiting for unfinished jobs….

解决办法如下或者替换XCode版本为6.3.2或者5.几的:

//OpenJDK9/jdk9/jdk/src/java.desktop/macosx/native/libosxapp/NSApplicationAWT.m//387行改成: if (NSApp != nil) { //[NSApp setDelegate: applicationDelegate]; [(NSApplication*)NSApp setDelegate: applicationDelegate]; if (applicationDelegate && qad) { [qad processQueuedEventsWithTargetDelegate: applicationDelegate]; qad = nil; } }

重新编译:

$ make clean$ make…OpenJDK9/jdk9/jdk/src/java.desktop/share/native/libawt/awt/image/awt_parseImage.c:855:33: error: comparison of array ‘rasterP->sppsm.offsets’ not equal to a null pointer is always true [-Werror,-Wtautological-pointer-compare] else if (rasterP->sppsm.offsets != NULL) { ~~~~~~~~~~~~~~~^~~~~~~ ~~~~1 error generated.make[3]: *** [OpenJDK9/jdk9/build/macosx-x86_64-normal-server-fastdebug/support/native/java.desktop/libawt/awt_parseImage.o] Error 1make[2]: *** [java.desktop-libs] Error 2make[2]: *** Waiting for unfinished jobs….ERROR: Build failed for target ‘default’ in configuration ‘macosx-x86_64-normal-server-fastdebug’ (exit code 2) Hint: If caused by a warning, try configure –disable-warnings-as-errors make[1]: *** [main] Error 2make: *** [default] Error 2

解决办法:

与其在那里苦苦挣扎,碍于面子硬撑,倒不如微笑着面对,

Mac OSX 10.10 Yosemite编译OpenJDK 9

相关文章:

你感兴趣的文章:

标签云: