Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unsatisfied link error when running native language code.

0 views
Skip to first unread message

Michael J. Pape

unread,
Jan 24, 1997, 3:00:00 AM1/24/97
to

I've started looking at using C/C++ code with Java, and I started by trying
out the example given in the on-line Java tutorial:

"URL:http://www.javasoft.com/nav/read/Tutorial/native/index.html"

I'm running this under SunOS 5.5 and Java JDK 1.0.2.

After creating the shared library containing the Java stub and native code,
and setting the LD_LIBRARY_PATH environment variable, I get the following
error.

////////////////////////////
eve% java MainApp
ld.so.1: /usr/share/src/local/bin/java/JDK/java/bin/../bin/sparc/java:
fatal: /home1/s/m/mp2200/public_html/java/env/lib/libhello.so: unknown file
type (/home1/s/m/mp2200/public_html/java/env/lib/libhello.so)
java.lang.UnsatisfiedLinkError: no hello in shared library path
at java.lang.Runtime.loadLibrary(Runtime.java)
at java.lang.System.loadLibrary(System.java)
at HelloWorld.<clinit>(HelloWorld.java:7)
at
java.lang.UnsatisfiedLinkError: displayHelloWorld
at MainApp.main(MainApp.java:4)
////////////////////////////

Apparently Java doesn't like the libhello.so file, but using "nm" on the
library looks good. i.e.,

eve% nm *.so

libhello.so[HelloWorld.o]:

[Index] Value Size Type Bind Other Shndx Name

[3] | 0| 0|SECT |LOCL |0 |2 |
[1] | 0| 0|FILE |LOCL |0 |ABS |HelloWorld.c
[5] | 0| 0|NOTY |GLOB |0 |UNDEF
|HelloWorld_displayHelloWorld
[4] | 0| 48|FUNC |GLOB |0 |2
|Java_HelloWorld_displayHelloWorld_stub
[2] | 0| 0|NOTY |LOCL |0 |2 |gcc2_compiled.

libhello.so[HelloWorldImp.o]:

[Index] Value Size Type Bind Other Shndx Name

[4] | 0| 0|SECT |LOCL |0 |2 |
[2] | 0| 0|SECT |LOCL |0 |3 |
[1] | 0| 0|FILE |LOCL |0 |ABS |HelloWorldImp.c
[5] | 0| 40|FUNC |GLOB |0 |2
|HelloWorld_displayHelloWorld
[3] | 0| 0|NOTY |LOCL |0 |2 |gcc2_compiled.
[6] | 0| 0|NOTY |GLOB |0 |UNDEF |printf


Any Ideas???

Michael J. Pape
mjp...@usgs.gov

Michael Averstegge

unread,
Jan 24, 1997, 3:00:00 AM1/24/97
to

Seems not to be current directory in LD_LIBRARY_PATH.
I got this error message in such case.

Greetings
Michael

Andreas Zisowsky

unread,
Jan 27, 1997, 3:00:00 AM1/27/97
to

"Michael J. Pape" <mjp...@usgs.gov> writes:

>eve% java MainApp
>ld.so.1: /usr/share/src/local/bin/java/JDK/java/bin/../bin/sparc/java:
>fatal: /home1/s/m/mp2200/public_html/java/env/lib/libhello.so: unknown file

Hi,

I am currently experimenting with Netscape's LiveConnect to establish
a cooperation between a Java applet and a plugin and I experienced the
same problem: Netscape rejected my shared library.

The solution: It seems it needs a C++ linking-style instead of a C
linking-style. So compile with g++ and link with
g++ -shared -o lib.so *.o (something like that).

Note: I experienced another problem calling the native code from
Java. The C-file generated with javah -jri -stubs that includes the
stub-method you want to implement, must be compiled with gcc instead
of g++. I don't know why, but if I compile everything with g++, then I
receive an exception, saying the native method is not implemented.

Hope this helps.

Ciao.
Andreas
--
Andreas Zisowsky | mailto: ziso...@fokus.gmd.de or zi...@cs.tu-berlin.de
GMD FOKUS | url: http://www.fokus.gmd.de/usr/zisowsky
Hardenbergplatz 2 | phone: (+49 30) 25499-262 secretary: -200 fax: -202
D - 10623 Berlin | PGP: finger [-l] ziso...@skylab.fokus.gmd.de or WWW

0 new messages