快速(用开发人员的时间)方式来使用Java中的许多C ++代码 [英] Fast (in means of developer time) way to use a lot of C++ code from Java

查看:124
本文介绍了快速(用开发人员的时间)方式来使用Java中的许多C ++代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我们正在设计一个物理应用程序,它将执行大量数据分析,但我们的重点是集成物理电子设备.

Background: We are designing a physics app, that will do a lot of data analysis, but our focus is integrating physical electronic equipement.

基本上,我希望能够调用 root (这是一个大数据分析库(使用C ++编写的CERN编写)或使用Java编写的C ++编写的库.基本上,使用Java的ROOT类的能力(并且这样做不会浪费很多时间来编写JNI包装器)对我们来说是一件大事(如果很难,很可能我们将使用Qt).

Basically I would like to be able to call root (it's a big data analysis library from CERN written in C++) library written in C++ library from Java. Basically ability to use ROOT classes from Java (and doing it without losing much time to code JNI wrappers) is a showstopper to us (if it will be hard, most probably we will be using Qt).

我可以想到以下方法

  • JNI-正如我所说-我们不想为每个类编写包装器. . .
  • JNA -JNA不提供C ++映射,但仅提供C.
  • SWIG -我没有使用它,但是听说它很难使用.
  • JNI - as I said - we dont want to write wrappers for every class. . .
  • JNA - JNA doesnt provide C++ mappings, but only C.
  • SWIG - I didn't use it, but heard it's hard to use.

其他可能让人联想到的东西:我们可以访问根源代码,但是我们不想更改它.我们希望结果具有可移植性.我们想坚持免费图书馆. 就像我说的那样,我们从一开始就可以使用很多ROOT代码,而不必大惊小怪.

Other things that may be revelant: we have access to root source code, but we dont want to change it. We want results to be portable. We would like to stick to free libraries. And as I said - we would be able to use much of the ROOT code from the beginning, without fuss.

推荐答案

任何选择,您都需要做一些包装.虽然您不想为每个类编写JNI包装器,但是您可以编写包含方法组的高级C ++类.然后,您只需要为更高级别的类编写包装器即可(该方法也适用于其他方法,而不仅仅是JNI).

With any choice, you're going to need to do some wrapping. While you don't want to write JNI wrappers for every class, you could write higher level C++ classes that encompass groups of methods. Then you only need to write wrappers for the higher level classes (this approach works for other methods too, not just JNI).

这篇关于快速(用开发人员的时间)方式来使用Java中的许多C ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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