Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JNI unsatisfied link eroor

Posted on 2004-10-12
16
1,029 Views
Last Modified: 2012-05-05
I am writing using JNI to translate web based queries generated in Java classes to C based queries over a socket connection.  Right now all the classes are in the same directory as much of the other C code.  At first, I had an unsatisfied link error due to not setting the proper java library path, but I fixed that.  I am still getting an unsatified link error, but this time in java's main method when invoking the native "submitQuery" method.  I haven't been able to figure out how to resolve this one.  Any assistance would be much appreciated.  This is being compiled and run on a Solaris machine.
0
Comment
Question by:tigress298
  • 5
  • 4
  • 2
  • +1
16 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12287687
The cause is your c++/c dll is not binded correctly with Java API
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 250 total points
ID: 12287698
The following link may shed some light on this:
http://developer.java.sun.com/developer/bugParade/bugs/4225434.html
0
 

Author Comment

by:tigress298
ID: 12287774
I am getting the following output when running the -verbose:jni command:

sfoste03@sunlp0001-(74): java -verbose:jni JNIQuery
[Loaded native library: /usr/java1.2/jre/lib/sparc/libjava.so]
[Loaded native library: /usr/java1.2/jre/lib/sparc/libzip.so]
[Dynamic-linking native method java/lang/Object.registerNatives ...]
[Dynamic-linking native method java/lang/Class.registerNatives ...]
[Dynamic-linking native method java/lang/Thread.registerNatives ...]
[Dynamic-linking native method java/lang/System.registerNatives ...]
[Dynamic-linking native method java/lang/Class.getPrimitiveClass ...]
[Dynamic-linking native method java/security/AccessController.getStackAccessControlContext ...]
[Dynamic-linking native method java/lang/System.initProperties ...]
[Dynamic-linking native method java/io/FileInputStream.initIDs ...]
[Dynamic-linking native method java/io/FileDescriptor.initIDs ...]
[Dynamic-linking native method java/io/FileOutputStream.initIDs ...]
[Dynamic-linking native method java/lang/System.setIn0 ...]
[Dynamic-linking native method java/lang/ClassLoader.getCallerClassLoader ...]
[Dynamic-linking native method java/lang/Class.forName0 ...]
[Dynamic-linking native method java/security/AccessController.doPrivileged ...]
[Dynamic-linking native method java/lang/System.setOut0 ...]
[Dynamic-linking native method java/lang/System.setErr0 ...]
[Dynamic-linking native method java/lang/Compiler.registerNatives ...]
[Dynamic-linking native method java/io/FileSystem.getFileSystem ...]
[Dynamic-linking native method java/io/UnixFileSystem.initIDs ...]
[Dynamic-linking native method java/security/AccessController.doPrivileged ...]
[Dynamic-linking native method java/io/UnixFileSystem.list ...]
[Dynamic-linking native method java/io/UnixFileSystem.canonicalize ...]
[Dynamic-linking native method java/io/UnixFileSystem.getBooleanAttributes0 ...]
[Dynamic-linking native method java/lang/ClassLoader.findLoadedClass ...]
[Dynamic-linking native method java/lang/ClassLoader.findBootstrapClass ...]
[Dynamic-linking native method java/security/AccessController.doPrivileged ...]
[Dynamic-linking native method java/lang/String.intern ...]
[Dynamic-linking native method java/lang/System.getCallerClass ...]
[Loaded native library: /usr/java1.2/jre/lib/sparc/libzip.so]
[Dynamic-linking native method java/util/zip/ZipFile.initIDs ...]
[Dynamic-linking native method java/util/zip/ZipFile.open ...]
[Dynamic-linking native method java/util/zip/ZipFile.getTotal ...]
[Dynamic-linking native method java/util/zip/ZipFile.getEntry ...]
[Dynamic-linking native method java/util/zip/ZipEntry.initIDs ...]
[Dynamic-linking native method java/util/zip/ZipEntry.initFields ...]
[Dynamic-linking native method java/util/zip/ZipFile.getCSize ...]
[Dynamic-linking native method java/util/zip/ZipFile.getMethod ...]
[Dynamic-linking native method java/util/zip/Inflater.initIDs ...]
[Dynamic-linking native method java/util/zip/Inflater.init ...]
[Dynamic-linking native method java/util/zip/Inflater.inflateBytes ...]
[Dynamic-linking native method java/util/zip/ZipFile.read ...]
[Dynamic-linking native method java/lang/Throwable.fillInStackTrace ...]
[Dynamic-linking native method java/io/FileInputStream.open ...]
[Dynamic-linking native method java/io/UnixFileSystem.getLength ...]
[Dynamic-linking native method java/io/FileInputStream.readBytes ...]
[Dynamic-linking native method java/lang/ClassLoader.defineClass0 ...]
[Unable to load native library: /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so]
ld.so.1: /usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java: fatal: relocation error: file /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so: symbol locs: referenced symbol not found
Exception in thread "main" [Dynamic-linking native method java/lang/Object.getClass ...]
[Dynamic-linking native method java/io/FileOutputStream.writeBytes ...]
java.lang.UnsatisfiedLinkError: no NewServerClient in java.library.path
[Dynamic-linking native method java/lang/Throwable.printStackTrace0 ...]
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.<init>(Throwable.java:94)
        at java.lang.Error.<init>(Error.java:50)
        at java.lang.LinkageError.<init>(LinkageError.java:43)
        at java.lang.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
        at java.lang.ClassLoader.loadLibrary(Compiled Code)
        at java.lang.Runtime.loadLibrary0(Runtime.java:473)
        at java.lang.System.loadLibrary(System.java:778)
        at <Unloaded Method>
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 250 total points
ID: 12288064
Hi tigress298,

>> [Unable to load native library: /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so]
>> ld.so.1: /usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java: fatal: relocation error: file /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so: symbol locs: referenced symbol not found

>> The cause is your c++/c dll is not binded correctly with Java API
right. you have to use javah on the compiled class. this tool generate a C header file you must use to make your C library.
0
 

Author Comment

by:tigress298
ID: 12288234
I did that.  Below are my steps of creation.

javac JNIQuery.java
javah -jni -o JNIQuery.h JNIQuery
made my NewServerClient.c class with #include "JNIQuery.h"
cc -G -o NewServerClient.so NewServerClient.c
java -verbose:jni JNIQuery
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12290125
Please show the java code where you load the library
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12290213
I want to see your c/c++ code. I suspect memory allocation problems in ur code
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12296011
>>cc -G -o NewServerClient.so NewServerClient.c
You should have in the static statement of your class :
    static{
        System.loadLibrary("NewServerClient"); // no extension
    }


>>ld.so.1: /usr/java1.2/bin/../jre/bin/../bin/sparc/native_threads/java: fatal: relocation error: >>file /data0/Baselines/sfoster/CPNet/bin/libNewServerClient.so: symbol locs: referenced symbol not found

The symbol named "locs" can't be found. You probably forgot to link your library with the one defining this symbol.
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12555221
I suggest to split the points : sudhakar_koundinya, Webstorm
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12584299
????

Some strange thing happened here
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12679509
:-)
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 12680445
:-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 116
Oracle SQL syntax check  without executing 6 74
ejb entity bean example 2 11
Java Eclipse Loop 3 20
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question