如何从本机代码调用 C 函数? [英] How to call a C function from a react-native code?

查看:58
本文介绍了如何从本机代码调用 C 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 react-native 开发了一个小型 android 应用程序.对于它的开发,它运行良好.现在为了满足一个小需求,我们需要调用一个用C编写的库.不知道有没有办法从JavaScript调用C代码!但我还是想问大家.

I have developed a small android application using react-native. For what it was developed, it works fine. Now to accommodate a small requirement, we need to call a library written in C. I am not sure if there will be a way to call the C code from JavaScript! But I still wanted to ask you all.

有没有办法从 react-native 做到这一点?就像我想调用 C 库中的一些函数一样.如果可能的话,你能建议怎么做吗?我如何开始测试一个非常基本的设置?

Is there a way to do this from react-native? Like I want to call some functions in the C library. If this possible, could you please suggest how? How could I start to test a very basic setup?

推荐答案

你将不得不写一些原生代码,搜索如何在 Android 上调用 C 库,然后寻找 react native 方式来链接原生代码使用 js 调用.

You are going to have to write some native code, search for how to call a C lib on Android, then look for react native way to link a native code with a js call.

原生模块链接 https://facebook.github.io/react-native/docs/native-modules-android.html

关于如何在 android 上运行 c/cpp 代码的 StackOverflow 问题 如何在android中使用c/cpp库/函数

StackOverflow question on how to run c/cpp code on android how to use c/cpp library/functions in android

这篇关于如何从本机代码调用 C 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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