Operating System - HP-UX
1831137 Members
2694 Online
110020 Solutions
New Discussion

Re: Loading native library fails within a Java program

 
Chamitha
Occasional Contributor

Loading native library fails within a Java program

I have written a simple Java file that simply loads a native library file using System.loadLibrary(). The native library file name is libACE.sl. MY java file is as follows:

import java.lang.Throwable;

class LoadNative {
public static void main(String args[])
{
String libname = "ACE";

try
{
System.loadLibrary(libname);
System.out.println("Library " +
libname + " successfully loaded");
}
catch (UnsatisfiedLinkError Err)
{
//System.out.println("error: " + Err);
Err.printStackTrace();
//return;
}
System.out.println("All done");
}
}

I have set my SHLIB_PATH to include the directory that contains libACE.sl. The Java program compiles sucessfully, however when run (using java LoadNative) it throws the following exception:

aCC runtime: Error 215 from shl_findsym(./libACE.sl,_shlInit)
/usr/lib/dld.sl: Unresolved symbol: openprot__7filebuf (data) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: cerr (data) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: typeid__XT9streambuf_ (data) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: xsputn__9streambufFPCci (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: __dt__9streambufFv (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: __ls__7ostreamFPCc (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: flush__7ostreamFv (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: doallocate__9streambufFv (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: open__8ofstreamFPCciT2 (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: tellp__7ostreamFv (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: close__11fstreambaseFv (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: __ct__9streambufFv_2 (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: __ct__8ofstreamFPCciT2 (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: seekoff__9streambufFlQ2_3ios8seek_diri (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: __dt__13Iostream_initFv (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: __ct__13Iostream_initFv_1 (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: seekpos__9streambufFli (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: setbuf__9streambufFPci (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: pbackfail__9streambufFi (code) from ./libACE.sl
/usr/lib/dld.sl: Unresolved symbol: xsgetn__9streambufFPci (code) from ./libACE.sl
Abort(coredump)

Can anyone make any sence of this error and let me know how I can avoid it? I havent got a clue!

I'm using HP-UX 11.11 with aCC compiler version 3.33
The libACE.sl library is an existing 3rd party library. I require to load this library in a project i'm doing hence the development of the test Java application! Also worth noting is I can re build the libACE.sl file if required using what ever compiler switches that maybe be needed.
2 REPLIES 2
Steve Steel
Honored Contributor

Re: Loading native library fails within a Java program

Hi

Do you have

Patch Name: PHSS_26263

Patch Description: s700_800 11.11 ld(1) and linker tools cumulative patch

Creation Date: 02/04/12

Post Date: 02/04/18

Hardware Platforms - OS Releases:
s700: 11.11
s800: 11.11
The new dynamic linker has support for a new
environment variable LD_PRELOAD through which libraries
can be dynamically loaded and used for symbol
resolution.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Mike Stroyan
Honored Contributor

Re: Loading native library fails within a Java program

Those missing symbols come from libstream.sl. It looks like the java command is linked with libCsup but not libstream. You may get your shared library working by linking it with -lstream. There is a working example of aCC jni at
http://www.hp.com/products1/unix/java/infolibrary/prog_guide/java1_3/JNI_java2.html#java_native_ac++

Follow the link line from that example.