[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Users] orekit-7.0 called from C/C++



I am using C++ on Windows, but using IDE (Eclipse foreseen). I think that going through .NET programming will be hard for me (as I really don't know anything about it). But thanks for proposing.

For information, I also found that GIWS might be an alternative to JNI (even if I'm not sure I am going to use it). [see http://forge.scilab.org/p/giws/].

2015-02-09 14:24 GMT+00:00 Hank Grabowski <hank@applieddefense.com>:
Are you doing C++ on a Linux stack or on a Windows stack using Visual Studio?  We've been experimenting with a technology called IKVM.  It allows you to run Java code within a .NET application.  It has some performance problems that we are trying to root out, if it's possible to, but it does work very well besides that.  You could use the Managed C++ .NET language to wire in unmanaged code into the managed code and thus get around the need for JNI.

On Mon, Feb 9, 2015 at 8:50 AM, Nicolas SIMI <nicolas.simi@gmail.com> wrote:
OK, I will try to use JNI, then.
Thank you for advice, I think they will help me a lot.
Nicolas

2015-02-09 13:24 GMT+00:00 Luc Maisonobe <Luc.Maisonobe@c-s.fr>:
Le 09/02/2015 14:04, SIMI Nicolas a écrit :
> Hello Everyone,

Hi Nicolas,

> I am completely new to OREKIT, but this library seems really powerful. I would
> like to use some OREKIT routines in an existing program coded in C/C++
> language.
>
> Do you think that it might be easily done? Do you have an example of such a
> use that I could inspire from in my particular case? I precise that event if I
> can program basic functions in Matlab or C/C++, I have no knowledge at all of
> programming in JAVA, PYTHON or JYTHON, and that introducing the use of Matlab
> for my purpose would make the program much more complex.


It is possible to use Orekit from C/C++ with any compiled language like
C or C++ using the standard JNI bindings (Java Native Interface). JNI is
very powerful as it support everything in Java. You can create objects,
trigger exceptions, catch exceptions, call Java or be called from Java
or both (for example if you write your own step or events handlers in
C++ and want Orekit to call them). We have used it successfully even
with Fortran integration in both directions (i.e. having chained calls
like a main program in fortran and embedded calls like fortran -> C ->
Java -> C -> fortran).

Be warned however that JNI is hard. It is really complex. The main
advices we can give you are:

 - create a dedicated interface layer between you code and
   Orekit
 - try to transfer only primitive data types (double, integers, ...)
   rather than complex structures
 - beware strings must be converted du unicode
 - beware arrays cannot be passed as is (i.e. you can't use a pointer
   to the first element to refer to the whole array, you have to wrap
   them in a real Java object array)

JNI is mainly interesting when you have lots of exchanges back and forth
between your program and Orekit. If your use case is rather a program
doing some preliminary work in C/C++, then transfer full control to
Orekit, and wait for the result, and then doing some final work
(displaying, reporting), it may be more efficient to use two separate
processes, one in C/C++ and another in Java rather than going through
the complexity of JNI.

Hope this helps,
Luc

>
> Thank you for your help,
> Nicolas
>