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报错
1755浏览 • 0回复 待解决
Openharmony 编译 openssl 依赖 icu库报错
872浏览 • 0回复 待解决
OpenHarmony-v4.0-Beta1 编译报错,求助
3348浏览 • 3回复 待解决
NDK开发是否有提供交叉编译工具
618浏览 • 1回复 待解决
OpenHarmony dcts无法编译通过
2312浏览 • 0回复 待解决
openHarmony2.0 hb编译问题
9506浏览 • 5回复 待解决
编译报错没有堆栈信息
516浏览 • 1回复 待解决
openharmony 新建third_party编译不到
3901浏览 • 1回复 待解决
下载编译Full-SDK报错
1296浏览 • 1回复 待解决
搭建鸿蒙环境时,编译报错
10926浏览 • 4回复 待解决
OpenHarmony-2.2-Beta2 编译失败,求助
7473浏览 • 1回复 已解决
初次安装DevEco Studio编译报错
5959浏览 • 1回复 待解决
openharmony编译安装hb前遇到这问题
6289浏览 • 1回复 待解决
在Camkelist配置so后,编译报错
320浏览 • 1回复 待解决
@Sendable编译报错,有什么方法解决?
653浏览 • 1回复 待解决
OLED 屏幕输出编译报错问题
9126浏览 • 2回复 待解决