public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joe Hoffert <jhoffert@dre.vanderbilt.edu>
To: Andrew Haley <aph@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: GCJ .jar to .so with native method
Date: Tue, 04 Dec 2007 16:35:00 -0000	[thread overview]
Message-ID: <1196786104.3362.47.camel@sirion.dre.vanderbilt.edu> (raw)
In-Reply-To: <18261.31076.962649.532047@zebedee.pink>

Hi, Andrew.

On Tue, 2007-12-04 at 15:59 +0000, Andrew Haley wrote: 
> Joe Hoffert writes:
>  > Hi, Andrew.
>  > 
>  > On Tue, 2007-12-04 at 15:16 +0000, Andrew Haley wrote:
>  > 
>  > OK. I've attached a zip file with everything that should be needed. The
>  > gcj-commands file simply contains the gcj and gcjh commands I used to
>  > generate the .so library and the .h header files.
> 
> Works for me:
> 
> zorro:tmp $  gcjh -classpath ./ricochet.jar multishot.examples.RicochetApp
> zorro:tmp $  gcj -shared -fPIC -Wl,-Bsymbolic ./ricochet.jar -o libricochet.so
> zorro:tmp $ gcj RicochetAppMain.cpp -L. -lricochet -fPIC  -lstdc++
> cc1plus: warning: command line option "-fbootclasspath=./:/usr/share/java/libgcj-4.1.2.jar" is valid for Java but not for C++

Ah! This is the missing piece for me. I was linking with g++. I was
assuming since I had a .so library and .h headers I could treat the
transformed .jar file like a C++ library. It never crossed my mind to
compile the C++ file with gcj and link everything with gcj.

I assume I will need to use gcj rather than g++ for all my C++ files. Is
this correct?

> zorro:tmp $  LD_LIBRARY_PATH=. ./a.out 
> Usage: RicochetApp GMS_id FDS_id startPortNumber [propertyString]
> 
> You really need to call JvCreateJavaVM() first.

In some other code I have I call JNI_CreateJavaVM. Is this different
from JvCreateJavaVM and, if so, do you know how it differs? The
prototype for JvCreateJavaVM doesn't exist in the jni.h file that I'm
using.

Adding this call raises some questions for me. Does this call add
overhead (and/or footprint)? I was (seemingly naively) assuming that
once the .jar file was converted to a .so file I was done with needing
any Java support. This doesn't seem to be the case. Why is the JVM still
needed?

Are there any other calls I should add?

> If this doesn't give you the same results, the problem is likely to be
> that you need a new version of gcj.

Thanks very much! You've been a tremendous help. I have struggled with
this C++/Java integration for a while.

-Joe

  reply	other threads:[~2007-12-04 16:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-04 13:20 Joe Hoffert
2007-12-04 13:28 ` Andrew Haley
2007-12-04 14:06   ` Joe Hoffert
2007-12-04 15:16     ` Andrew Haley
     [not found]       ` <1196782972.3362.22.camel@sirion.dre.vanderbilt.edu>
2007-12-04 15:59         ` Andrew Haley
2007-12-04 16:35           ` Joe Hoffert [this message]
2007-12-04 16:43             ` Andrew Haley
2007-12-04 17:47               ` Joe Hoffert
2007-12-04 18:06                 ` David Daney
2007-12-04 18:13                 ` Andrew Haley
2007-12-04 19:04                   ` Joe Hoffert
2007-12-05 11:02                     ` Andrew Haley
     [not found]                       ` <1329.129.59.82.132.1196873567.squirrel@www.dre.vanderbilt.edu>
2007-12-05 17:32                         ` Andrew Haley
2007-12-05 17:42                           ` Andrew Haley
2007-12-05 17:56                             ` jhoffert
2008-01-10 21:39                             ` Joe Hoffert
2008-01-10 21:46                               ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1196786104.3362.47.camel@sirion.dre.vanderbilt.edu \
    --to=jhoffert@dre.vanderbilt.edu \
    --cc=aph@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).