Mac M1芯片编译openjdk报错问题解决

使用命令: sudo sh configure --with-target-bits=64

用mac m1芯片编译openjdk一直报错:

configure: The tested number of bits in the target (64) differs from the number of bits expected to be found in the target (32)

configure: error: Cannot continue.

/Users/mac/Documents/jdkcompile/jdk-jdk-11-ga/build/.configure-support/generated-configure.sh: line 82: 5: Bad file descriptor

configure exiting with result code 1

原因很奇怪,大家都知道mac m1的系统是ARM64架构的,看了下generated-configure.sh脚本中对with-target-bits这样赋值的:

我们可以加行代码,输出看下VAR_CPU_BITS具体是多少,结果输出的是32,但是其实我们的系统本身是64位的,所以你把编译命令改为sudo sh configure --with-target-bits=32后面依然会报错的

复制代码
  {
    echo "${VAR_CPU_BITS}: =============="
  }

这时候只需要强制加把OPENJDK_TARGET_CPU_BITS的值改为64就可以解决了,记得加在

复制代码
OPENJDK_TARGET_CPU_BITS="$VAR_CPU_BITS"后面一行,或者替换掉这行
复制代码
  OPENJDK_TARGET_CPU_BITS=64

然后再试下命令:sudo sh configure --with-target-bits=64

ok完美解决

相关推荐
jxy999841 分钟前
mac mini 安装java JDK 17
java·开发语言·macos
Figo_Cheung1 小时前
Figo关于OpenClaw(MacOS)安装前环境变量设置保姆级教程
macos·性能优化·个人开发
未来侦察班10 小时前
一晃13年过去了,苹果的Airdrop依然很坚挺。
macos·ios·苹果vision pro
普通网友15 小时前
苹果笔记本(Mac)连接手机完全指南
macos·智能手机
Aftery的博客17 小时前
Xcode运行报错:SDK does not contain ‘libarclite‘ at the path
macos·cocoa·xcode
楚轩努力变强1 天前
iOS 自动化环境配置指南 (Appium + WebDriverAgent)
javascript·学习·macos·ios·appium·自动化
猫头虎2 天前
如何解决 OpenClaw “Pairing required” 报错:两种官方解决方案详解
网络·windows·网络协议·macos·智能路由器·pip·scipy
皮卡车厘子3 天前
Mac 挂载目录
macos
良逍Ai出海3 天前
在 Windows & macOS 上安装 Claude Code,并使用第三方 Key 的完整教程
windows·macos
热爱生活的五柒3 天前
linux/mac/wsl如何使用claude code,并配置免费的硅基流动API?(官方的需要付费订阅)
linux·运维·macos