Operating System - Linux
1753856 Members
7494 Online
108809 Solutions
New Discussion юеВ

Re: Error: java.lang.UnsatisfiedLinkError

 
Gerardo AYALA
New Member

Error: java.lang.UnsatisfiedLinkError

I've an problem with JNI make in TUXEDO 8.1 and Java 1.4, I want make an simple example for use both. My compilation string is:

cc -Ae +u4 +Z -c -D_HPUX -D_POSIX_C_SOURCE=199506L +DD64 \
-I /tuxedo8/tuxedo8.1/include -I/opt/java1.4/include -I/opt/java1.4/include/hp-ux \
-lc -lnsl -lpthread -L /tuxedo8/tuxedo8.1/lib -lfml -lfml32 -ltux -lengine -lbuft -lgiconv -lusort \
cImpl.c

This generate an .o file then run the next command:

cc -b -o libcImpl.sl cImpl.o +DD64 \
-lc -lnsl -lpthread -L /tuxedo8/tuxedo8.1/lib -lfml -lfml32 -ltux -lengine -lbuft -lgiconv -lusort

And generate the libcImpl.sl "Shared Library" so try load this library with a java program:

java TestJava2CallingNative cImpl

The result is a message of subject . . .

/libcImpl.sl: specified file is not a shared library, or a format error was detected.

How can verify my .sl file or what are doing bad?

thank you
6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: Error: java.lang.UnsatisfiedLinkError

There is nothing that tells you in more detail what is wrong? The name of the symbol in question?

cc -b -o libcImpl.sl cImpl.o +DD64 \
-lc -lnsl -lpthread -L/tuxedo8/tuxedo8.1/lib -lfml -lfml32 -ltux -lengine -lbuft -lgiconv -lusort

You have your libs out of order. -lc should be removed. System libs should be after user libs, move -lnsl -lpthread to the end.

/libcImpl.sl: specified file is not a shared library, or a format error was detected.

>How can verify my .sl file or what are doing bad?

To check if the right format, you could try
$ file libcImpl.sl

I assume you are using a 64 bit java (-d64) to go with your 64 bit lib??

If you can't get java to give you more details on unsats, you should write a dummy main that uses shl_load or dlopen on your lib.

Gerardo AYALA
New Member

Re: Error: java.lang.UnsatisfiedLinkError

Dennis,

change the makefile as you suggest and then compile the source (.c) the result is ( />file libcImpl.sl)

libcImpl.sl: ELF-64 shared object file - PA-RISC 2.0 (LP64)

But when execute my java program send me the error:
Error: java.lang.UnsatisfiedLinkError

So what recompile without some libraries leave the makefile:

cc -b -o libcImpl.sl cImpl.o

The result was:

/>file libcImpl.sl
libcImpl.sl: PA-RISC2.0 shared library -not stripped

/>java TestJava2CallingNative cImpl
Shared library cImpl load
call to method sayHelloWorld
C say HelloWorld via stdio
/usr/lib/dld.sl: Unresolved symbol: userlog (code) from .//libcImpl.sl
/usr/lib/dld.slAbort(coredump)

I Know that need link the definition of "userlog" function, but make this generate an link error:

/usr/ccs/bin/ld: /tuxedo8/tuxedo8.1/lib/libfml.sl: Mismatched ABI. 64-bit PA shared library found in 32-bit link.

For this reason my makefile need link in mode 64-bit all libraries.

Question: How can know that my JAVA is from 64-bit?

thank



Dennis Handly
Acclaimed Contributor

Re: Error: java.lang.UnsatisfiedLinkError

>change the makefile as you suggest and then compile the source (.c)

This would not fix your problem but make sure you don't have others.

/>>java TestJava2CallingNative cImpl
>/usr/lib/dld.sl: Unresolved symbol: userlog (code) from .//libcImpl.sl

This seems to tell you exactly what was wrong.

>Know that need link the definition of "userlog" function, but make this generate an link error:
/usr/ccs/bin/ld: /tuxedo8/tuxedo8.1/lib/libfml.sl: Mismatched ABI. 64-bit PA shared library found in 32-bit link.

You need to compile and link with +DD64.

>Question: How can know that my JAVA is from 64-bit?

You need to pass in "-d64" to get 64 bit.

Have you tried my suggestion of a dummy main to load your JNI?
Gerardo AYALA
New Member

Re: Error: java.lang.UnsatisfiedLinkError

Dennis,

I compile with +DD64 option and libraries include successful.
But the error now is:

Error: java.lang.UnsatisfiedLinkError: /jni_tst/libcImpl.sl: some symbol required by the shared library could not be found.

The core was not generated used -d64 option.

I make my main dummy for load JNI and execute successful, no have problem, the problem is when link the TUXEDO libreries.

Dennis Handly
Acclaimed Contributor

Re: Error: java.lang.UnsatisfiedLinkError

>Error: java.lang.UnsatisfiedLinkError: /jni_tst/libcImpl.sl: some symbol required by the shared library could not be found.

That's not very helpful. :-(
The PA aC++ runtime makes sure you get a list before you abort.

>The core was not generated used -d64 option.

Can you use that option with java?

>I make my main dummy for load JNI and execute successful, no have problem, the problem is when link the TUXEDO libreries.

You have to link exactly the same as your real application, with TUXEDO. Using shl_load with BIND_IMMEDIATE would give you the list of all unsats.

I suppose you can also get them with -Wl,+vnoshlibunsats. (If you left off the -lc as I said above, add it back (after -lpthread), look at the messages, then remove it.)
Dennis Handly
Acclaimed Contributor

Re: Error: java.lang.UnsatisfiedLinkError

Can you show the complete error message? I just got this reported:
java.lang.UnsatisfiedLinkError: xx.so:
xx.so' is not a valid load module: Bad machine type

A message similar to this would indicate you need that -d64.