有没有办法从Java使用JNI调用C ++的STL库? [英] Is there a way to call the STL Libraries of C++ from Java using JNI?

查看:235
本文介绍了有没有办法从Java使用JNI调用C ++的STL库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从JNI调用STL库,我相信JNI为本地调用提供了一个C类接口,我们如何实现这个C ++模板库?

Is there a way to call STL libraries from JNI, I believe JNI provides a C like interface for native calls, how do we achieve this for the C++ template libraries?

推荐答案

我同意,如果你只是寻找平原STL,你可能可以使用Java库。但是,如果你坚持包装STL,SWIG在JNI中提供了一些STL包装(参见的基本机制),它应该产生相对稳定,测试的代码。

I agree that if you're looking for just the plain STL, you could probably use a Java library instead. However, if you insist on wrapping STL, SWIG provides some STL wrapping in JNI out of the box (see this for the basic mechanism), which should produce relatively stable, tested code.

这篇关于有没有办法从Java使用JNI调用C ++的STL库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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