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完美解决

相关推荐
獨枭6 小时前
配置 macOS 上的 Ruby 开发环境
开发语言·macos·ruby
库奇噜啦呼11 小时前
push [特殊字符] present
macos·ios·cocoa
安和昂12 小时前
【iOS】多线程NSOperation,NSOperationQueue
macos·ios·cocoa
咕噜签名分发冰淇淋12 小时前
Flutter 打包 iOS 苹果 IPA 应用有哪些优势?如何实现?
macos·objective-c·cocoa
st紫月18 小时前
用虚拟机安装macos系统之后进入Boot Manager页面
macos
tonngw1 天前
【Mac 从 0 到 1 保姆级配置教程 16】- Docker 快速安装配置、常用命令以及实际项目演示
macos·docker·容器·开源·github·docker desktop·orbstack
ItisNagatoYuki1 天前
Mac M芯片 RAG 极简流程 安装 ragflow + LM studio
macos
云攀登者-望正茂2 天前
如何在mac上安装podman
macos·podman
江梦寻2 天前
MacOS下Homebrew国内镜像加速指南(2025最新国内镜像加速)
开发语言·后端·python·macos·架构·策略模式
*Lisen2 天前
重新安装解决mac vscode点击不能跳转问题
ide·vscode·macos