java.lang.UnsatisfiedLinkError - native method

Discussion in 'Java' started by andrej.frelih@gmail.com, Nov 13, 2007.

  1. Guest

    Hello.

    I have one problem regarding the native method compilation.
    I get the following error for ONLY ONE FUNCTION THAT I RECENTLY ADDED:


    Exception in thread "main" java.lang.UnsatisfiedLinkError: helloworld
    at
    com.hp.openview.ib.api.jopc.JOpcApplication.helloworld(Native Method)
    at
    com.hp.openview.ib.api.jopc.JOpcApplication.hellokrava(JOpcApplication.java:
    854)
    at OpcApplication.main(OpcApplication.java:40)


    For example the old function ApplModify and ApplGet work fine.

    One thing that i have noticed when i run nm(prints the list of common
    object names) on the compiled library
    is that my NEWLY added helloworld function contains this "__Fv" at the
    end of the name that is why i think it cannot be found by the java
    class. So i think it is a problem with the library compilation, but i
    don't know where to look.

    ApplGet| 36088|extern|code |$CODE$
    ApplGet| 36088|extern|entry |
    ApplModify| 36232|extern|code |$CODE$
    ApplModify| 36232|extern|entry |
    helloworld__Fv| 36496|extern|entry |
    helloworld__Fv| 36496|extern|code |$CODE$

    Does anyone have an idea please, or needs more information(code
    snapshots).


    Regards,
    Andrej
    , Nov 13, 2007
    #1
    1. Advertising

  2. On Tue, 13 Nov 2007 06:05:52 -0800, wrote:
    > Exception in thread "main" java.lang.UnsatisfiedLinkError: helloworld


    [...]

    > my NEWLY added helloworld function contains this "__Fv" at the end
    > of the name that is why i think it cannot be found by the java
    > class.


    How (exactly) do you compile the native library? Are you using a C
    compiler, or a C++ compiler?

    Is the failing method declared with extern "C"? It should be, and it
    will be if you exactly obeyed the declaration that javah provided for
    you in the generated header file. If the signature of your
    implementation differs from that in the header file, the extern "C"
    javah provided is no longer helping you.

    /gordon

    --
    Gordon Beaton, Nov 13, 2007
    #2
    1. Advertising

  3. Guest

    On 13 nov., 15:19, Gordon Beaton <> wrote:
    > On Tue, 13 Nov 2007 06:05:52 -0800, wrote:
    > > Exception in thread "main" java.lang.UnsatisfiedLinkError: helloworld

    >
    > [...]
    >
    > > my NEWLY added helloworld function contains this "__Fv" at the end
    > > of the name that is why i think it cannot be found by the java
    > > class.

    >
    > How (exactly) do you compile the native library? Are you using a C
    > compiler, or a C++ compiler?


    I am using the hp-ux aC++ compiler.

    >
    > Is the failing method declared with extern "C"? It should be, and it
    > will be if you exactly obeyed the declaration that javah provided for
    > you in the generated header file. If the signature of your
    > implementation differs from that in the header file, the extern "C"
    > javah provided is no longer helping you.


    Functions are all marked with extern "C" and i did obey the
    declaration( at least i hope so)
    of javah.

    The .h file looks like that:

    extern "C" {
    JNIEXPORT jint JNICALL Java_helloworld
    (JNIEnv *, jobject);

    JNIEXPORT jint JNICALL Java_ApplModify
    (JNIEnv *, jobject, jlong, jlong, jlong);

    ..... there are more functions

    }

    I very much appreciate your help Gordon.
    Need more code?
    Regards,
    A
    >
    > /gordon
    >
    > --
    , Nov 13, 2007
    #3
  4. On Tue, 13 Nov 2007 07:45:13 -0800, wrote:
    > I am using the hp-ux aC++ compiler.


    And your command line?

    > Functions are all marked with extern "C" and i did obey the
    > declaration( at least i hope so) of javah.
    >
    > The .h file looks like that:


    Of course the generated header file is correct. What does *your* file
    look like, in particular the failing method? Do you include the header
    file?

    /gordon

    --
    Gordon Beaton, Nov 13, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    795
  2. Delio Nasso
    Replies:
    5
    Views:
    2,133
    Roedy Green
    May 28, 2007
  3. Replies:
    1
    Views:
    4,525
    Roedy Green
    Nov 13, 2007
  4. debapriya.patra
    Replies:
    0
    Views:
    1,029
    debapriya.patra
    Mar 18, 2009
  5. newage
    Replies:
    0
    Views:
    1,118
    newage
    Dec 5, 2010
Loading...

Share This Page