ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: LD_LIBRARY_PATH problems using Ant to call C++ JNI code
Date Fri, 14 Jun 2002 20:15:02 GMT
The JVM is a DLL. Your process you started with Ant is a separate process
that the Ant one. So both these processes have their own JVM (own version of
the DLL loaded in their address space). To be really sure, create a
java.rmi.dgc.VMID in both VMs, and you'll see they are indeed two different
objects.

Did you printout the LD_LIBRARY_PATH from your native code before creating
the VM?

On Windows, the JVM.dll doesn't depend on anything, so you can load the DLL
using an absolute path in the LoadLibrary call. Isn't it the same on
FreeBSD? Can't you pass an absolute path to ldload()?

Just throwing dumb ideas at you. --DD

-----Original Message-----
From: Guerry Semones [mailto:guerry@tsunamiresearch.com] 
Sent: Friday, June 14, 2002 2:57 PM
To: Ant Users List
Subject: RE: LD_LIBRARY_PATH problems using Ant to call C++ JNI code

I'll definitely give that a try. 

I agree that having it not work after setting things in the Makefile was
indeed weird.

One interaction that I've wondered about was between the JVM executing
Ant and the JVM that I invoke in my own code, and if somehow the two are
the same or some other weird interaction.  A more detailed picture of
what is happening:

1. "ant test" from command line
   2. launches the "ant" shell script 
      3. the "ant" shell script launchs a JVM running the Ant class
         4. the ant class reads the build.xml and invokes the "test"
target "make test"
            5. "make test" launches my C++ code
               6. My C++ invokes a JVM (or uses an existing one) and
attachs my C++ thread to it.

NOW, what if the JVM I get on invocation IS the Ant JVM.  I'm shady on
the JNI-side of what actually happens here.  I *know* that if I've
gotten a JVM in *my* code from a previous invocation, that I get the
previous one again on subsequent invocations.  That is JNI by design.
What I'm not sure of is if my process is running (kind of) in
association with a JVM-invoked process (Ant), do I get Ant's
pre-existing JVM, and does Ant's internal environment for its JVM do
something to the LD_LIBRARY_PATH.

Oh well, I'll try you "env" suggestion!

Thanks,

Guerry

-----Original Message-----
From: Dominique Devienne [mailto:DDevienne@lgc.com] 
Sent: Friday, June 14, 2002 1:22 PM
To: 'Ant Users List'
Subject: RE: LD_LIBRARY_PATH problems using Ant to call C++ JNI code


First let me just say that it seems you tried everything I could think
of, and that defining LD_LIBRARY_PATH in the makefile doesn't work is
weird. The only remaining thing you could try is to use the 'env'
command. I haven't used Unix for a few years now, but I vaguely remember
env can be used to set an env. var. for a program it starts itself, like
in:

env LD_LIBRARY_PATH=... make test

If FreeBSD supports this form of env, then maybe by <exec>ing that from
Ant would help (instead of bash -c 'make test')!?!? Somehow I doubt it,
given the fact that what you tried was unsuccessful, but it's worth a
try. --DD

-----Original Message-----
From: Guerry Semones [mailto:guerry@tsunamiresearch.com] 
Sent: Friday, June 14, 2002 12:07 PM
To: ant-user@jakarta.apache.org
Subject: LD_LIBRARY_PATH problems using Ant to call C++ JNI code

This one is a bit convoluted to describe.  We are running a Freebsd unix
environment using Ant to control some building and testing.  In the case
where we're having problems, Ant is running C++ tests by having the Ant
script call "make test" to run the tests.  If we can resolve this issue,
then our build/test cycle will be fully automated on FreeBSD.

We are running: Ant 1.4.1 / JDK 1.3.1 / FreeBSD 4.5-RC

The build.xml target is:

<target name="test" description="Run all unit tests">
  <exec executable="/usr/local/bin/bash" failonerror="true" dir="myDir">
    <arg line="-c 'make test'" />
  </exec>
</target>

The LD_LIBRARY_PATH is set in the environment to have the following
JNI-required stuff:

/usr/local/jdk1.3.1/jre/lib/i386:/usr/local/jdk1.3.1/jre/lib/i386/classi
c:/usr/local/jdk1.3.1/jre/lib/i386/native_threads:/usr/local/jdk1.3.1/jr
e/lib/i386

To be concise, this is the way things are called, and then I'll state
the issue we are having:

1. Invoking "ant test" on the command line
   2. Ant calls "make test"
      3. Make calls C++ unit test (CppUnit)
         4. C++ code uses JNI to call JVM instance  <-- LD_LIBRARY_PATH
needed
            5. JVM instance executes Java bytecode

The breakdown occurs at step #4.  For some reason, the LD_LIBRARY_PATH
is lost from the Ant environment (overwritten?) and Ant returns the
following error from the C++ unit test code:

     [exec] t10MyTest.testThisThing
     [exec] .Cannot open
"/usr/local/jdk1.3.1/jre/lib/i386//libhpi.so".Cannot open
"/usr/local/jdk1.3.1/jre/lib/i38 6//libhpi.so".Cannot open
"/usr/local/jdk1.3.1/jre/lib/i386//libhpi.so"...............Cannot open
"/usr/local/jdk1. 3.1/jre/lib/i386//libhpi.so"F
     [exec] .Cannot open "/usr/local/jdk1.3.1/jre/lib/i386//libhpi.so"F

If the test is executed WITHOUT Ant by using MAKE directly, then the
error does NOT occur:

1. Invoking "make test" on the command line
   2. Make calls C++ unit test (CppUnit)
      3. C++ code uses JNI to call JVM instance 
         4. JVM instance executes Java bytecode

Something in the Ant environment seems to be overwriting the
LD_LIBRARY_PATH.  I have tried putting the LD_LIBRARY_PATH settings into
every conceivable place I could conceive of :-).  For example, I've set
it in the following places:

-- in the shell environment
-- as parameters in the Makefile
-- as parameters in the Ant shell script that executes Ant
-- as an <env> tag in the Ant build script itself
-- each of these singly and together and several other convoluted things
I've tried....

Any ideas?  Thanks in advance!

Guerry

--
To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message