JNI linux problems

Discussion in 'Java' started by Ilghiz Ibraghimov, Aug 28, 2003.

  1. Dear All,

    would you suggest me how to solve my problem!

    I have SuSE Linux 7.3, j2sdk1.4 and compile one web example of JNI:

    gcc -c JNIPrintWrapperImpl.cpp
    ar cru libJNIPrintMessage.so JNIPrintWrapperImpl.o
    export LD_LIBRARY_PATH=.
    java JNIPrintMain

    gives the following message error:

    Exception in thread "main" java.lang.UnsatisfiedLinkError:
    /home2/ilgis/JAVA/DEITEL/2/chapters/appG/figG_01/libJNIPrintMessage.so:
    /home2/ilgis/JAVA/DEITEL/2/chapters/appG/figG_01/libJNIPrintMessage.so:
    ELF file's phentsize not the expected size

    Thank you for your ideas!

    Sincerely

    Ilghiz

    *************************************
    public class JNIPrintMain{
    public static void main( String args[] )
    { JNIPrintWrapper wrapper = new JNIPrintWrapper();
    wrapper.printMessage( "Hello World\n" );
    }
    }
    *************************************
    public class JNIPrintWrapper {
    static { System.loadLibrary( "JNIPrintMessage" ); }
    public native void printMessage( String message );
    }
    *************************************
    #include <iostream.h>
    #include "JNIPrintWrapper.h"
    JNIEXPORT void JNICALL Java_JNIPrintWrapper_printMessage
    ( JNIEnv * env, jobject thisObject, jstring message )
    {
    jboolean copied;
    const char* charMessage =
    env->GetStringUTFChars( message, &copied );
    cout << charMessage;
    env->ReleaseStringUTFChars( message, charMessage );
    }
    *************************************
    Ilghiz Ibraghimov, Aug 28, 2003
    #1
    1. Advertising

  2. On Thu, 28 Aug 2003 17:29:43 +0200, Ilghiz Ibraghimov wrote:
    > I have SuSE Linux 7.3, j2sdk1.4 and compile one web example of JNI:
    >
    > gcc -c JNIPrintWrapperImpl.cpp
    > ar cru libJNIPrintMessage.so JNIPrintWrapperImpl.o
    > export LD_LIBRARY_PATH=.
    > java JNIPrintMain
    >
    > gives the following message error:
    >
    > Exception in thread "main" java.lang.UnsatisfiedLinkError:


    That isn't how to create a shared library.

    Try this instead:

    gcc -fPIC -shared JNIPrintWrapperImpl.cpp -o libJNIPrintMessage.so

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Aug 28, 2003
    #2
    1. Advertising

  3. On Thu, 28 Aug 2003 17:56:19 +0200, Ilghiz Ibraghimov wrote:
    > undefined symbol: __gxx_personality_v0
    >
    > There is no __gxx_... symbols in my code, but it is in the *.so
    > library, and I cannot understand where to find it, please, help me
    > once more!


    Are you using gcc 3.2?

    Try adding a link option to the command line:

    gcc -fPIC -shared -lstdc++ JNIPrintWrapperImpl.cpp -o libJNIPrintMessage.so

    See also (although I'm not sure if this is the same problem):
    http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Java-Exceptions.html#Java Exceptions

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Aug 28, 2003
    #3
  4. Ilghiz Ibraghimov, Aug 28, 2003
    #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. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    835
    Alex Hunsley
    Nov 4, 2003
  2. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    889
    Pasturel Jean-Louis
    Mar 3, 2004
  3. vasanth
    Replies:
    0
    Views:
    2,660
    vasanth
    Jan 25, 2005
  4. vasanth
    Replies:
    0
    Views:
    606
    vasanth
    Jan 25, 2005
  5. bgabrhelik
    Replies:
    0
    Views:
    784
    bgabrhelik
    Sep 29, 2009
Loading...

Share This Page