is jni.h platform / VM specific?

G

Gordon Beaton

During runtime on target device I get following error when loading my
JNI library:

Exception in thread "main" java.lang.UnsatisfiedLinkError: MyLibrary
(Unresolved symbols)

Is it possible that root cause is I compile it with incompatible jni.h
header?
Library name and location (LD_LIBRARY_PATH) are correct.

The library itself is dependent on additional libraries that can't be
found at runtime. What makes you suspect jni.h specifically?

Use e.g. ldd libname.so to see the dependencies, and determine which
ones can't be resolved.

/gordon

--
 
D

Dzikus

Hello,
During runtime on target device I get following error when loading my
JNI library:

Exception in thread "main" java.lang.UnsatisfiedLinkError: MyLibrary
(Unresolved symbols)

Is it possible that root cause is I compile it with incompatible jni.h
header?
Library name and location (LD_LIBRARY_PATH) are correct.

Than you in advance
Dominik
 
D

Dzikus

The library itself is dependent on additional libraries that can't be
found at runtime. What makes you suspect jni.h specifically?

Use e.g. ldd libname.so to see the dependencies, and determine which
ones can't be resolved.

/gordon

--
Unfortunately I don't have ldd available on target :/
On build platform it does not work:

$ ldd libMyLib.so
../libMyLib.so:
ldd: ./libMyLib.so: Exec format error


I suspect jni.h because I worked with VM from another supplier before,
and jni.h (and other headers) was delivered together with VM.
This dedicated version of jni.h differs from standard Sun's jni.h

Full error message:

....
class load: java/util/jar/Attributes$Name
class load: MyLib/Application
class load: MyLib.Application from: file:XXXXX
class load: App
class load: App from: file:XXXXX
unknown relocation type
unknown relocation type
....
unknown relocation type
unknown relocation type
class load: java/lang/LinkageError
class load: java/lang/UnsatisfiedLinkError
Exception in thread "main" java.lang.UnsatisfiedLinkError: MyLib
(Unresolved symbols)
class load: java/lang/StackTraceElement[]
at java.lang.ClassLoader.loadLibraryWithPath(Unknown Source)
at java.lang.ClassLoader.loadLibraryWithClassLoader(Unknown
Source)
at java.lang.System.loadLibrary(Unknown Source)
at jsal.Application.<clinit>(Unknown Source)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(Unknown Source)
at java.lang.J9VMInternals.initialize(Unknown Source)
 
D

Dzikus

I have checked library dependencies using objdump.exe
Dependencies are:

NEEDED libcpp.so.4
NEEDED libc.so.2

Both libraries are on LDD_LIBRARY_PATH.
 
G

Gordon Beaton

Unfortunately I don't have ldd available on target :/
On build platform it does not work:

On the build platform you should be able to get this and other
information with e.g. objdump or readelf, which you likely have anyway
as part of your cross compilation environment.

However based on your full error message (in particular "unknown
relocation type"), I think it looks more like you haven't built the
shared library correctly for the target platform.

What is the target platform? What does "file libMyLib.so" say? What
file tell you about the object files that libMyLib.so consists of?

/gordon

--
 
H

Hendrik Maryns

Dzikus schreef:
Hello,
During runtime on target device I get following error when loading my
JNI library:

Exception in thread "main" java.lang.UnsatisfiedLinkError: MyLibrary
(Unresolved symbols)

Is it possible that root cause is I compile it with incompatible jni.h
header?
Library name and location (LD_LIBRARY_PATH) are correct.

The platform-specific part of jni is in jni_md.h. md is for ‘machine
dependent’.

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFHnxrye+7xMGD3itQRAhndAJoDnGhki58cZUogPA60iUhLbZVstgCeNvDy
RNd3uvv9Auaufe8wx+8jMvs=
=eTZ9
-----END PGP SIGNATURE-----
 
D

Dzikus

The platform-specific part of jni is in jni_md.h. md is for 'machine
dependent'.
Do you know how to get this header for
IBM J9 2.3 QNX arm-32 (J2ME Foundation Specification v1.0)

I searched in IBM page without success so far ... :/
 
H

Hendrik Maryns

Dzikus schreef:
Do you know how to get this header for
IBM J9 2.3 QNX arm-32 (J2ME Foundation Specification v1.0)

I searched in IBM page without success so far ... :/

It is supposed to come with your Java sdk.

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFHnzqZe+7xMGD3itQRAmrfAJsH8k3I9Hl/rHUN49ZHFypWaFO3QACfY8rg
yPZEOhutvG2hrBpgYLDdEcg=
=Nvbp
-----END PGP SIGNATURE-----
 
A

Arne Vajhøj

Dzikus said:
During runtime on target device I get following error when loading my
JNI library:

Exception in thread "main" java.lang.UnsatisfiedLinkError: MyLibrary
(Unresolved symbols)

Is it possible that root cause is I compile it with incompatible jni.h
header?

I don't think so.

A bad jni.h could result in some data corruption when
type size is different between expected and actual.

UnsatisfiedLinkError is a problem finding or loading
the native lib.

Arne
 
D

Dzikus

I have found the root cause:
1. First of set of headers specific for platform / JVM is needed
2. unknown relocation type - this error is related to JNI *.so
library. In QXN *.so libraries doesn't work linked against libXXX.a.
One have to link it against *.so or libXXXS.a

Thank you for your answers - they were very helpfull in finding the
solution
Best regards
Dominik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top