ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: UnsatisfiedLinkError when invoking native library from junit task
Date Wed, 14 Jun 2006 12:35:36 GMT
Juan Jimenez wrote:
> Back in June 2004 there was a thread briefly discussing the problem of
> native libraries having dependencies on further native libraries and the
> apparent lack of support in ANT to modify Path or LD_LIBRARY_PATH as
> appropriate.  I am facing the problem (which I explain in more detail 
> below)
> and I am posting this in the hope that things have moved on or someone 
> had a
> bright idea on how to tackle this.
> 
> ##### The Problem #####
> I use Cruisecontrol to build several branches of several different
> projects.  The build itself is done through ANT scripts which I have
> refactored extensively to avoid duplication.  As such, all projects have a
> standard location where they keep third party dependencies.  That includes
> both jar files and natibe libraries (DLLs for Windows and SOs for RHEL-3).
> 
> Within the <junit> task I have included the following inner elements:
> 
>            <sysproperty key="java.library.path" path="${junit.lib.path}"/>
>            <sysproperty key="LD_LIBRARY_PATH" path="${ junit.lib.path}"/>
>            <sysproperty key="PATH" path="${junit.lib.path}"/>
> 
> where junit.lib.path is set to a path structure that includes all project
> specific dependencies (including DLLs and SOs).
> 
> Our Java code can find any native library it needs (be it DLL or SO).
> However, if that native library tries to load further native libraries we
> get an UnsatisfiedLinkError
> 
> Below is a sample stack trace showing that libIRTKJava.so cannot find
> libIRTKApi.so even though they are both in the same directory:
> 
> java.lang.UnsatisfiedLinkError:
> /vob/gcib/etrading/projects/PricingImpl/lib/package/libIRTKJava.so:
> libIRTKApi.so: cannot open shared object file: No such file or directory at
> java.lang.ClassLoader$NativeLibrary.load(Native Method) at
> java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751) at
> java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676) at
> java.lang.Runtime.loadLibrary0(Runtime.java:822) at
> java.lang.System.loadLibrary(System.java:992) at
> irtkjava.LibLoader.loadNativeLibrary(LibLoader.java:46) at
> com.bofa.ib.pricer.impl.irtk.IRTKCurveBuilderTest.initialise(
> IRTKCurveBuilderTest.java:21) at
> com.bofa.ib.pricer.impl.irtk.IRTKCurveBuilderTest.setUp(
> IRTKCurveBuilderTest.java:34)
> 
> Am I going to be forced to look into a nominated directory and preload
> anything that matches *.so before invoking a non-forked JVM for the unit
> tests?
> 

This looks a bit like the problem that on windows, Java loads files 
using ::LoadLibrary, not

::LoadLibraryEx( LOAD_WITH_ALTERED_SEARCH_PATH)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibrary.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibraryex.asp

if they did that, then when you loaded a library from a dir, it would 
add that dir to the search path for the next libraries to load.

This is the full search order

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/dynamic-link_library_search_order.asp

Presumably you are running <junit> forked? I think you also need to make 
sure that your path and library search path includes the existing env 
variables.

-steve

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


Mime
View raw message