【问题标题】:Building a c++ application with gradle on host linux aarch64在主机 linux aarch64 上使用 gradle 构建 c++ 应用程序
【发布时间】:2021-08-14 13:26:08
【问题描述】:

我的主机是 Android Galaxy Tab S4 上的 linux aarch64 机器,安装了 Termux 作为我的开发环境。 安装在 Termux 中的是 NDK v22、Clang 12.0.2、Gradle 7.1.1、android-sdk (30.0.3) 和 kotlin 1.5.21。

我用 gradle 初始化了一个新的 c++ 应用程序项目,并初始化了默认模板项目文件和目录。

当我现在尝试构建项目时,出现以下错误:


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugCpp'.
> Error while evaluating property 'compilerVersion' of task ':app:compileDebugCpp'
   > No tool chain is available to build C++ for host operating system 'Linux' architecture 'aarch64':
       - Tool chain 'visualCpp' (Visual Studio):
           - Visual Studio is not available on this operating system.
       - Tool chain 'gcc' (GNU GCC):
           - Don't know how to build for host operating system 'Linux' architecture 'aarch64'.
       - Tool chain 'clang' (Clang):
           - Don't know how to build for host operating system 'Linux' architecture 'aarch64'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
1 actionable task: 1 executed

我的用例是构建 c++ 库,然后使用 kotlin/native 并在 gradle/kotlin/ndk 等的帮助下将所有内容集成到 apk 中作为最后一项任务。

这个错误是什么意思? 真的不支持linux aarch64主机还是我需要更改build.gradle文件中的一些配置设置?

我搜索了 gradle 文档、互联网和 kotlin/native 手册,但找不到解决方案。

提前感谢您的帮助。

【问题讨论】:

    标签: android c++ kotlin gradle arm64


    【解决方案1】:

    如果不使用 gradle 直接调用 Clang 会找到吗? 请确保您可以从命令行使用 Clang 编译任何内容。

    那么您可能需要按照https://docs.gradle.org/current/userguide/native_software.html#native_binaries:tool_chain 中所述为 Gradle 微调您的原生工具链

    【讨论】:

    • 是的,clang 在 cli 中正常工作。从通常的“Hello World”、jni-project 和 android ndk 来看,一切都很好
    • 当我尝试这个链接中的例子时,我得到一个错误:> Invalid NativePlatform: linux_aarch64.
    • 对于 linux_aarch64,另请参见 discuss.gradle.org/t/…。就算年纪大了也希望能帮到你
    • 感谢您的链接。我试过这个例子没有成功。日志: > 未能通知项目评估侦听器。 > 没有工具链支持为主机操作系统“Linux”架构“aarch64”构建 C++:-工具链“clang”(Clang):-不知道如何为主机操作系统“Linux”架构“aarch64”构建. > 没有工具链支持为主机操作系统“Linux”架构“aarch64”构建 C++:-工具链“clang”(Clang):-不知道如何为主机操作系统“Linux”架构“aarch64”构建.
    猜你喜欢
    • 2015-04-18
    • 1970-01-01
    • 2015-10-02
    • 1970-01-01
    • 2021-09-12
    • 2018-01-17
    • 1970-01-01
    • 2018-11-18
    • 2019-06-09
    相关资源
    最近更新 更多