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

相关推荐
青州从事52115 小时前
20260108【mac】【brew】【docker】安装
macos·docker·eureka
centor21 小时前
国际版 UnitySetup-Android-Support 安装 Mac 设备
android·macos
旭日跑马踏云飞1 天前
【Mac】实用技巧-在新窗口中打开当前文件夹
macos
林疏safe1 天前
CAD2026最新mac的安装教程收集免费分享
macos
Digitally1 天前
如何高效安全地将 iPhone 与 Mac 同步
安全·macos·iphone
程序员允诺1 天前
办公 WiFi 二次隔离下的远程桌面解决方案实践(Mac → Win11)
macos
hudawei9961 天前
win和Mac在创建python虚拟环境,启动环境等操作的异同
windows·python·macos·虚拟环境
2501_916008891 天前
没有 Mac 如何在 Windows 上创建 iOS 应用描述文件
android·macos·ios·小程序·uni-app·iphone·webview
提笔忘字的帝国1 天前
【教程】macOS 如何完全卸载 Java 开发环境
java·开发语言·macos
数据雕塑家2 天前
【网络故障排查实战】多台机器互ping异常:MAC地址冲突引发的网络“薛定谔猫“现象
网络·macos