Android NDK:用cmake指定app_abi

发布于 2025-02-10 16:20:42 字数 291 浏览 1 评论 0 原文

我想为我的Android项目编译一些 c 文件。我使用 ndk cmake 。我想为所有可用的CPU类型生成 .so 文件。在线大多数教程基于 ndk-Build ,其中指定 app_abi:= app_abi:= all application.mk file中的所有。如何使用 cmake 进行相同的操作? 我的CMAKE版本是3.18.1 谢谢。

I want to compile some c files for my android project. I'm using NDK with cmake. And I want to generate the .so files for all available CPU types. Most of the tutorials online are based on ndk-build, in which they specify the APP_ABI := all in Application.mk file. How can I do the same with cmake?
My cmake version is 3.18.1
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愛放△進行李 2025-02-17 16:20:42

对于“纯” CMAKE项目,这是一个生成的构建树无法完成的。

假设您正在将工具链文件的路径传递到cmake(使用 -dcmake_toolchain_file = $ ndk/build/build/cmake/android.toolchain.toolchain.cmake ),您也应该以 android_abi /代码>参数。 请参见在这里

有关可能的值, 对于每个ABI,类似:

MyProjectDir/
  build_x86_64/
  build_x86/
  build_arm64/
  build_armeabi/
  src/
  ...

另一方面,您正在使用一个由Gradle Marand的项目工作,那么ABI会自动由Gradle控制,并且只需担心,如果您 not not 想要为所有ABIS建造。

正常构建应用程序,当您获得APK时 - 打开它(本质上是邮政编码)。内部应该是 lib 目录,其中包含每个ABI的子目录。

For a "pure" CMake project, this cannot be done with a single generated build tree.

Assuming you are passing a path to a toolchain file to CMake (with -DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake), you should also be passing in an ANDROID_ABI argument. For possible values see here

You're then expected to have a separate build dir for each ABI, something like:

MyProjectDir/
  build_x86_64/
  build_x86/
  build_arm64/
  build_armeabi/
  src/
  ...

If, on the other hand, you are working with a Gradle-managed project, then the ABI is automatically controlled by Gradle and you only need to worry if you don't want to build for all ABIs.

Build your app as normal, and when you get an APK - open it (it's essentially a ZIP archive). Inside it should be a lib directory containing subdirectories for each ABI.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文