如何将C code到JNI code [英] How to transform C code to JNI Code

查看:139
本文介绍了如何将C code到JNI code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有C code( TESTFILE 的.c)中,我想在Android应用程序来使用,使用JNI。
这code含有纯C code和它里面有很多方法。此外,还要求一些C头文件(文件1 的.H,的文件2 的.H)。

I have C code (testFile.c) that I want to used in Android App, using JNI. This code contains pure C code and it has many methods inside. Moreover, it also calls some C header files (file1.h, file2.h).

例如:
TESTFILE 的.C

#include "file1.h"
#include "file2.h"

void myMethod1()
{
    ...
    ...
}
void myMethod2()
{
    ...
    ...
}
void myMethod3()
{
    ...
    ...
}

我是否有能力改变整体的 TESTFILE 的.C到JNI code,或者只是变换了一些方法,将我后来使用(不是全部)?
是否也应该改变C code头文件(file1.h和file2.h)里面,或者我只是变换C ++ code在testFile.c?

Whether I have to transform whole of testFile.c to JNI code, or just transform some methods that will i used later (not all of them)? Should i also transform c code inside header file (file1.h and file2.h), or i just transform c code in testFile.c?

推荐答案

或者,如果您的Java和C code之间的接口非常简单,但在Android上使用JNI的整个过程不熟悉,你可以或多或少地合并你的C code到从NDK的HELLO-JNI的例子。你开始的东西,建造和运作问题的关键是,你加一点所需要的位,如果你遇到问题,你可以备份和你分手了什么阶段,它弄清楚。

Or if the interface between your Java and C code is extremely simple but the overall process of using jni on Android is unfamiliar, you can more or less merge your C code into the hello-jni example from the ndk. The point being that you start with something that builds and works, add what you need bit by bit and if you run into issues you can back up and figure out at what stage you broke it.

这篇关于如何将C code到JNI code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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