简体   繁体   English

PhoneGAP在Android平台上访问C ++库

[英]PhoneGAP Accessing C++ Library on Android Platform

I need make one call to a C++ library from my HTML5 PhoneGAP application on the Android Platform. 我需要从Android平台上的HTML5 PhoneGAP应用程序中调用C ++库。 What is the best way to invoke the C++ Library? 调用C ++库的最佳方法是什么? Do I need to first wrap in JNI? 我需要先包装JNI吗? Note I am not accessing anything Android specific. 注意我没有访问任何特定于Android的东西。 Just using a C++ library. 仅使用C ++库。 Now I know for Android there is possibility to write custom phonegap plugin, but in this case I need to pull in C++ library so not sure if plugin would work for this. 现在,我知道对于Android,可以编写自定义phonegap插件,但是在这种情况下,我需要引入C ++库,因此不确定插件是否可以为此工作。

This one could get a bit complicated. 这可能会有点复杂。 Pardon my ignorance about PhoneGAP, but assuming you have some Java code executing, you should be able to use JNI calls. 请原谅我对PhoneGAP的无知,但假设您正在执行一些Java代码,则应该能够使用JNI调用。 But you can't make JNI calls to C++ classes and you may have trouble making JNI calls to C++ functions (for obvious reasons, functions with templates will not work, and C++ functions will have name mangling.) 但是您不能对C ++类进行JNI调用,并且可能难以对C ++函数进行JNI调用(出于明显的原因,带有模板的函数将不起作用,而C ++函数将具有名称修饰。)

So, before you can access the library via JNI, you probably need to make a C interface on top of the C++ one that you can call into. 因此,在通过JNI访问该库之前,可能需要在可调用的C ++之上创建一个C接口。

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

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