openharmony 交叉编译openjdk报错

openjdk17,ubuntu20.04,OHOS (dev) clang version 15.0.4

configure 命令为

./configure --openjdk-target=aarch64-linux --with-toolchain-type=clang --with-debug-level=slowdebug

错误信息如下:

checking for aarch64-linux-ld... [not found]
checking for ld... /usr/bin/ld
configure: Using clang linker version 2.38 [GNU ld (GNU Binutils for Ubuntu) 2.38]
configure: WARNING: Ignoring value of AR from the environment. Use command line variables instead.
checking for aarch64-linux-ar... [not found]
checking for ar... /usr/bin/ar
configure: WARNING: Ignoring value of STRIP from the environment. Use command line variables instead.
checking for aarch64-linux-strip... [not found]
checking for strip... /usr/bin/strip
configure: WARNING: Ignoring value of NM from the environment. Use command line variables instead.
checking for aarch64-linux-nm... [not found]
checking for nm... /usr/bin/nm
configure: WARNING: Ignoring value of OBJCOPY from the environment. Use command line variables instead.
checking for aarch64-linux-gobjcopy... [not found]
checking for gobjcopy... [not found]
checking for aarch64-linux-objcopy... [not found]
checking for objcopy... /usr/bin/objcopy
configure: WARNING: Ignoring value of OBJDUMP from the environment. Use command line variables instead.
checking for aarch64-linux-gobjdump... [not found]
checking for gobjdump... [not found]
checking for aarch64-linux-objdump... [not found]
checking for objdump... /usr/bin/objdump
checking for aarch64-linux-c++filt... [not found]
checking for c++filt... /usr/bin/c++filt
checking for cc... /usr/bin/cc
checking for CC... [not found]
checking for g++... /usr/bin/g++
checking for nm... /usr/bin/nm
checking for ar... /usr/bin/ar
checking for objcopy... /usr/bin/objcopy
checking for strip... /usr/bin/strip
configure: The BuildC compiler (located as /usr/bin/cc) does not seem to be the required clang compiler.
configure: The result from running with --version was: "cc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
configure: error: A clang compiler is required. Try setting --with-tools-dir.
configure exiting with result code 1

请问这是什么问题,有人做过oh平台上的jdk编译吗?

openharmony
openjdk
编译
2024-06-15 16:43:01
浏览
已于2024-6-15 16:46:21修改
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
鱼弦CTO
1

从你提供的错误信息来看,主要有以下几个问题:


交叉编译工具链中的某些工具(如 aarch64-linux-ld、aarch64-linux-ar 等)未找到。

配置脚本找到了 GCC 编译器,但找不到 Clang 编译器。

为了解决这些问题,可以按照以下步骤进行操作:


1. 安装并设置交叉编译工具链

确保安装了合适的 AArch64 交叉编译工具链。可以通过以下命令安装:



sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu


2. 安装并设置 Clang 编译器

确保安装了 Clang 编译器,并将其路径添加到 PATH 环境变量中:



sudo apt-get install clang-15
export PATH=/path/to/clang/bin:$PATH


3. 设置环境变量

在运行 configure 脚本之前,确保设置好所有必要的环境变量。例如:



export AR=aarch64-linux-gnu-ar
export LD=aarch64-linux-gnu-ld
export NM=aarch64-linux-gnu-nm
export STRIP=aarch64-linux-gnu-strip
export OBJCOPY=aarch64-linux-gnu-objcopy
export OBJDUMP=aarch64-linux-gnu-objdump
export CC=clang
export CXX=clang++


4. 运行 configure 脚本

运行 configure 脚本时,使用参数指定 Clang 编译器路径和其他相关设置:



./configure --openjdk-target=aarch64-linux --with-toolchain-type=clang --with-debug-level=slowdebug --with-tools-dir=/path/to/clang/bin


示例配置

假设 Clang 编译器位于 /usr/bin,可以使用以下命令:



export AR=aarch64-linux-gnu-ar
export LD=aarch64-linux-gnu-ld
export NM=aarch64-linux-gnu-nm
export STRIP=aarch64-linux-gnu-strip
export OBJCOPY=aarch64-linux-gnu-objcopy
export OBJDUMP=aarch64-linux-gnu-objdump
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++


./configure --openjdk-target=aarch64-linux --with-toolchain-type=clang --with-debug-level=slowdebug --with-tools-dir=/usr/bin


验证环境配置


在运行 configure 前,可以通过以下命令验证是否正确配置了环境变量:



echo $CC  # 应输出 /usr/bin/clang
echo $CXX # 应输出 /usr/bin/clang++
which ${AR} # 应输出路径 /usr/bin/aarch64-linux-gnu-ar 或类似路径
which ${LD} # 应输出路径 /usr/bin/aarch64-linux-gnu-ld 或类似路径


如果一切正常,重新运行 configure,它应该能够找到所需的工具和编译器。

分享
微博
QQ
微信
回复
2024-07-09 09:41:43
相关问题
OpenHarmony 编译原生设置settings报错
2988浏览 • 0回复 待解决
HarmonyOS 怎么交叉编译curl、openssl库?
372浏览 • 1回复 待解决
交叉编译环境配置问题
131浏览 • 1回复 待解决
Openharmony 编译 openssl 依赖 icu库报错
2604浏览 • 0回复 待解决
native交叉编译第三方库
163浏览 • 1回复 待解决
OpenHarmony-v4.0-Beta1 编译报错,求助
4860浏览 • 3回复 待解决
NDK开发是否有提供交叉编译工具
1765浏览 • 1回复 待解决
OpenHarmony dcts无法编译通过
3430浏览 • 0回复 待解决
openHarmony2.0 hb编译问题
10973浏览 • 5回复 待解决
openharmony 新建third_party编译不到
5564浏览 • 1回复 待解决
openharmony编译安装hb前遇到这问题
7469浏览 • 1回复 待解决
openharmony编译时怎么修改current_toolchain
1816浏览 • 0回复 待解决
编译报错Found exception如下
1338浏览 • 1回复 待解决
编译OpenHarmony2.0失败,求助一下
8861浏览 • 3回复 已解决
搭建鸿蒙环境时,编译报错
12980浏览 • 4回复 待解决
HarmonyOS native audio 录制编译报错
183浏览 • 1回复 待解决
下载编译Full-SDK报错
2317浏览 • 1回复 待解决