how to interface between different languages

E

eddiekwang

Hello,
I need to write some C++ code that can be later invoked by another
program that is written in a different lanuage (it can be Java, Perl,
etc. I don't know ahead of time). How can I interface my C++ program
and the other program if I don't want to write a wrapper for every
single language ?

I need to pass a pointer between the C++ program and the other program.

Thank you in advance!
Eddy
 
M

Mike Wahler

Hello,
I need to write some C++ code that can be later invoked by another
program that is written in a different lanuage (it can be Java, Perl,
etc. I don't know ahead of time). How can I interface my C++ program
and the other program if I don't want to write a wrapper for every
single language ?

I need to pass a pointer between the C++ program and the other program.

Standard C++ only provides an 'interface' with one other language: C.
Look up "extern C" in a C++ book.(*) Interfacing with any other languages
will be platform specific operations. Check documentation for the langauge
translators (and possibly operating systems) in which you're interested.

(*) incompatibilities among translators can still give
unexpected results. I recommend only using translators
whose vendors specifically state will work together
correctly.

-Mike
 
M

Michael O'Keeffe

This is a whole subject in and of itself, there is no simple way.

Probably the method closest to the way you describe your requirements
is to use CORBA, and there are many great C++ implementations, for
example omniORB.

http://omniorb.sourceforge.net/

Other solutions - XML-RPC, MOMs, SOAP, etc etc to give you some search
keys.
 
M

Michael O'Keeffe

"Interfacing with any other languages will be platform specific
operations. Check documentation for the langauge translators (and
possibly operating systems) in which you're interested. "

Yes, using that solution would be plaform specific, and yes, that would
be a mess (although surely folks have done it), and that's why folks
came up with standards like CORBA, which hide all those messy details,
to an extent, so people don't have to reinvent the wheel.

And with open-source projects like omniORB, if you can compile a C++
program on your platform, you should be set.

http://omniorb.sourceforge.net/
 
C

Calum Grant

> Hello,
> I need to write some C++ code that can be later invoked by another
> program that is written in a different language (it can be Java, Perl,
> etc. I don't know ahead of time). How can I interface my C++ program
> and the other program if I don't want to write a wrapper for every
> single language ?

It's unfortunate that there's no standard interface to other languages.
I've always wanted to write a unified wrapper for all languages that
interface with C/C++, but I have never gotten around to doing it.
> I need to pass a pointer between the C++ program and the other program.

Either the language/C interface has a "pointer" type, or you could
convert it to an int. However it would be an opaque pointer, similar to
a void*. But if the language passed you the pointer back, you could
cast it back to the right type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top