Discussion:
Unsatisfied Link Error
(too old to reply)
Kamran Hameed
2008-03-26 09:07:20 UTC
Permalink
folks i am new to MPI. i am trying to write a simple Hello World
Program using some one's written code of MPI

the code is

import mpi.*;
public class Hello
{
public Hello(){}
public static void main(String[]args) throws Exception
{

MPI.Init(args);
System.out.println("Hello World");
MPI.Finalize();

}
}

Now when i run it.. as

mpirun -np 2 Hello.sh

it gives me error



Exception in thread "main" java.lang.UnsatisfiedLinkError:
mpjdev.Status.init()V
at mpjdev.Status.init(Native Method)
at mpjdev.Status.<clinit>(Status.java:41)
at mpi.MPI.<clinit>(MPI.java:78)
at Hello.main(Hello.java:8)



Now what i get from this error is that in file Status.java at line 41
there is a native call which it is not able to find.

Now i have already added the native folder in my CLASSPATH as

export CLASSPATH=$CLASSPATH:/home/kamran/code/src/native/

but still the exception persists


Note that the native folder contains files Status.c Status.h
Status.o

Apparantly it should work but exception still persists
Ross A. Finlayson
2008-03-26 21:55:28 UTC
Permalink
Post by Kamran Hameed
folks i am new to MPI. i am trying to write a simple Hello World
Program using some one's written code of MPI
the code is
import mpi.*;
public class Hello
{
public Hello(){}
public static void main(String[]args) throws Exception
{
MPI.Init(args);
System.out.println("Hello World");
MPI.Finalize();
}
}
Now when i run it.. as
mpirun -np 2 Hello.sh
it gives me error
mpjdev.Status.init()V
at mpjdev.Status.init(Native Method)
at mpjdev.Status.<clinit>(Status.java:41)
at mpi.MPI.<clinit>(MPI.java:78)
at Hello.main(Hello.java:8)
Now what i get from this error is that in file Status.java at line 41
there is a native call which it is not able to find.
Now i have already added the native folder in my CLASSPATH as
export CLASSPATH=$CLASSPATH:/home/kamran/code/src/native/
but still the exception persists
Note that the native folder contains files Status.c Status.h
Status.o
Apparantly it should work but exception still persists
For JNI (Java <-> Native interface) code there is a different
environment variable for the libmpi.so path, java.library.path, than
CLASSPATH for Java classes.

It varies how that is configured.

Also you need to compile the native implementation, where the header
Status.h is generated form javah Status.java, into a shared library, so
it looks like "libStatus.so", then in the static initializer of the
class use the System.loadLibrary("Status"), or something along those lines.

It varies how that is done.

Ross
Kamran Hameed
2008-03-27 09:20:58 UTC
Permalink
Hello Ross

First of all thanks for your reply. Its been 2 days i am facing this
stupid error. You said about compiling the header files into .so
files. Well that is also already done in the /lib folder of the MPI
code i am using. In that folder (lib), there are four files

ls parallel/mpj/lib/

libmpjbuf.so
libmpjdev.so
mpjbuf.dll
mpjdev.dll


And i have this folder in my classpath as well as in LD_LIBRARY_PATH.
Still i am facing this error...

Any idea?
Ross A. Finlayson
2008-03-27 20:09:06 UTC
Permalink
Post by Kamran Hameed
Hello Ross
First of all thanks for your reply. Its been 2 days i am facing this
stupid error. You said about compiling the header files into .so
files. Well that is also already done in the /lib folder of the MPI
code i am using. In that folder (lib), there are four files
ls parallel/mpj/lib/
libmpjbuf.so
libmpjdev.so
mpjbuf.dll
mpjdev.dll
And i have this folder in my classpath as well as in LD_LIBRARY_PATH.
Still i am facing this error...
Any idea?
Hi Kamran,

No, I don't really have other ideas. You might set an environment
variable java.library.path that points to those, you could from the Java
command line but mpirun or however you are launching the program might
or might not have that kind of env.var. picked up by the Java
interpreter/JIT. It is necessary that the System.loadLibrary is invoked
and successfully loads to native shared library before invoking the
native methods.

System.loadLibrary("mpjbuf");
System.loadLibrary("mpjdev");

On Windows that should load mpjbuf.dll, UNIX libmpjbuf.so, different
platforms have different name formation.

That should be somewhere in the static initializer of the class or
before the class' native methods are used.

Here's an idea, try and write a minimal plain Java application and run
that from the command line and see if it works simply instantiating the
class outside mpirun or so.

I think that the configuration of the library location for the native
code should be in the documentation for the compiler, i.e., in the JDK
documentation for the platform(s).

Good luck,

Ross F.
Kamran Hameed
2008-03-28 12:21:31 UTC
Permalink
Thanks alot Ross.

Loading...