MAC编译OpenJDK8:详细步骤及问题解决办法(含独家解决办法)

  参考:

https://blog.csdn.net/lizhengjava/article/details/105629780

https://www.cnblogs.com/micrari/p/7018474.html

  • 安装JDK8

https://blog.csdn.net/quantum7/article/details/108448170

  • 安装brew

https://blog.csdn.net/quantum7/article/details/108452241

  • 安装各种工具
brew install mercurial
brew install freetype
brew install ant
brew install ccache
brew install autoconf
brew install llvm
brew install binutils

 gcc、g++

  • 安装xcode

在应用商业中安装。

  • 下载源码
# 经常失败
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u-dev/

建议早上下载github,非常快: 

https://github.com/AdoptOpenJDK/openjdk-jdk8u

  • 修改脚本gcc.make

hotspot/make/bsd/makefiles/gcc.make

注释:

# Compiler warnings are treated as errors
# ifneq ($(COMPILER_WARNINGS_FATAL),false)
#   WARNINGS_ARE_ERRORS = -Werror
# endif

注释:

# ifeq ($(USE_CLANG),)
#   ifneq ($(CC_VER_MAJOR), 2)
#     DEPFLAGS += -fpch-deps
#   endif
# endif

加上:

LFLAGS += -stdlib=libstdc++

  • 修改脚本generate-config.sh

common/autoconf/generate-config.sh

搜索compiler is required,全部注释相应的语句。

搜索gnu++,注释。

  • 编译freetype

https://blog.csdn.net/quantum7/article/details/108462040

  • 编译
NEW_INCLUDE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
export   CFLAGS="-I$NEW_INCLUDE"
export CXXFLAGS="-I$NEW_INCLUDE"

NEW_LIB=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
export LDFLAGS="-L${NEW_LIB}"

export LIBRARY_PATH=$NEW_LIB:$LIBRARY_PATH

make clean

chmod 777 configure

./configure \
    --with-freetype=`pwd`/../freetype-2.10.2

make all
  • 错误

MAC clang: error: include path for libstdc++ headers not found

https://blog.csdn.net/quantum7/article/details/108466760

error: ‘&&‘ within ‘||‘ [-Werror,-Wlogical-op-parentheses]/Users/tsit/tsjdk8-project/tsjdk8/hotspot/

https://blog.csdn.net/quantum7/article/details/108466864

clang: error: unknown argument: ‘-fpch-deps‘

https://blog.csdn.net/quantum7/article/details/108466971

iostream file not found

https://blog.csdn.net/quantum7/article/details/108486354

ld: library not found for -lstdc++

https://blog.csdn.net/quantum7/article/details/108487437

猜你喜欢

转载自blog.csdn.net/quantum7/article/details/108460867