通过NDK在Android中使用C库 [英] Use C library in Android over NDK

查看:61
本文介绍了通过NDK在Android中使用C库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做什么:

我已经找到了一个 C库,该库可以计算音频流的音调,并希望在Android中使用它.

I've found a C library which computes an audio stream's pitch and want to use it in Android.

我想不用移植它,我也可以在NDK的帮助下使用它,对吗?

I thought instead of porting it I could also use it with the help of the NDK, right?

这是如何工作的?我必须安装NDK,然后呢?我可以像在Android中一样正常调用此C库的功能吗?

How does this work? I have to install the NDK, of course, and then? Can I call functions of this C library just as normal in Android?

我要导入"的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"显然是我需要导入的另一个文件.

The file "second_c_file.h" is another file that I need to import, obviously.

感谢您的帮助!

推荐答案

有关如何开始使用NDK的很好的教程可以是

A good tutorial for how to start working with the NDK can be found here. And yes, you should be able to get it to compile and call it from the NDK without many changes (assuming the code doesn't reference other libraries).

这篇关于通过NDK在Android中使用C库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆