简体   繁体   English

如何使用带有Gradle的Android Studio在Android上使用NDK从C ++构建静态库?

[英]How to build static library from C++ using NDK on Android using Android Studio with Gradle?

I have a project written in C++ and I want to build a static library to be able to link against it in other projects. 我有一个用C ++编写的项目,我想构建一个静态库,以便能够在其他项目中链接它。 But Android Studio along with NDK produces only shared library objects which are for me not usable (I need static objects). 但Android Studio和NDK只生成共享库对象,这对我来说是不可用的(我需要静态对象)。 I use gradle plugin to build the code. 我使用gradle插件来构建代码。

While the code compiles I cannot find a way to get a "libname.a" file. 当代码编译时,我无法找到获取“libname.a”文件的方法。

Anybody knows the magic behind this in Gradle ? 有人知道Gradle背后的魔力吗?

While not well familiar with the NDK Gradle supports building native static libraries. 虽然不熟悉NDK Gradle支持构建本机静态库。 You can see an example in C++ with Gradle or learn more about it in gradle user guide Native Binaries chapter . 您可以在C ++中使用Gradle查看示例,或者在gradle用户指南Native Binaries章节中了解有关它的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM