Android NDK:用cmake指定app_abi
我想为我的Android项目编译一些 c
文件。我使用 ndk
cmake
。我想为所有可用的CPU类型生成 .so
文件。在线大多数教程基于 ndk-Build
,其中指定 app_abi:= app_abi:= all
。如何使用 application.mk
file中的所有 cmake
进行相同的操作?
我的CMAKE版本是3.18.1
谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于“纯” CMAKE项目,这是一个生成的构建树无法完成的。
假设您正在将工具链文件的路径传递到cmake(使用
-dcmake_toolchain_file = $ ndk/build/build/cmake/android.toolchain.toolchain.cmake
),您也应该以android_abi /代码>参数。 请参见在这里
有关可能的值, 对于每个ABI,类似:
另一方面,您正在使用一个由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 anANDROID_ABI
argument. For possible values see hereYou're then expected to have a separate build dir for each ABI, something like:
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.