Integrating gcj and C
Tom Tromey
tromey@redhat.com
Mon Jun 30 18:05:00 GMT 2003
>>>>> "Robin" == Robin Garner <robin.garner@iname.com> writes:
Robin> Does anyone know what needs to be done to embed C++ into C
Robin> without having a C++ main module ?
Generically, simply linking in the required libraries should work.
However, libgcj is a little different. It requires some special
setup, which "gcj --main" provides.
You could run "gcj --main=... -fsave-temps" (or something similar,
maybe I misspelled the option) and look at the resulting C file. This
isn't supported from release to release, but it should work for the
time being.
Once you have the correct startup code you'll also need to link in the
proper libraries. You can run "gcj -v --main=..." on a dummy program
to see what happens there. The correct answer varies from platform to
platform.
Robin> Does anyone on this list know what is required (or
Robin> who/where to ask) ? Performance is important (vital), so
Robin> using CNI over JNI is essential.
A more supported approach than the above is to use the invocation API.
There are both CNI and JNI forms. However I've seen (and ignored,
sigh) bug reports against the CNI version. Still, it might work for
you (I've also ignored the status of potential fixes). This will
solve the startup problem but you'll still need the -v trick when
linking.
Tom
More information about the Java
mailing list