android - 通过 NDK 在 Android 中使用 C 库

标签 android c android-ndk

我想做什么:

我找到了 C library which computes an audio stream's pitch并想在 Android 中使用它。

我想除了移植它我还可以在 NDK 的帮助下使用它,对吧?

这是如何运作的?当然,我必须安装 NDK,然后呢?我可以在 Android 中正常调用此 C 库的函数吗?

我要“导入”的 C 语言库:

#include "second_c_file.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>

#ifndef max
#define max(x, y) ((x) > (y)) ? (x) : (y)
#endif
#ifndef min
#define min(x, y) ((x) < (y)) ? (x) : (y)
#endif

int _power2p(int value) {
    ...
}

typedef struct _minmax {
    int index;
    struct _minmax *next;
} minmax;

double _test_calculate(double * var1, int var2, int var3) {
    ...
}

显然,文件“second_c_file.h”是我需要导入的另一个文件。

感谢您的帮助!

最佳答案

关于如何开始使用 NDK 的一个很好的教程可以是 found here .是的,您应该能够编译它并从 NDK 调用它而无需进行太多更改(假设代码不引用其他库)。

关于android - 通过 NDK 在 Android 中使用 C 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8390811/

相关文章:

android - 为一个文件禁用 ANDROID 编译标志

c - 这在c中是什么意思? char *array[]= { "**", "**", "**"};

android - 如何以编程方式在android中执行linux命令?

java - android.content.contextwrapper.getResources 中的空指针异常

android - 在 flutter 单元测试中访问 rootBundle

c - C 中的格式说明符及其作用?

c - 打印程序栈的内容(C语言)

android - 如何摆脱旧版 Cocos2Dx 项目中的 "deprecated"警告

android - 如何卸载旧版本的android sdk构建工具?

android - 制作动态壁纸