UnsatisfiedLinkError while loading library using System.loadLibrary

Discussion in 'Java' started by ratheesh.pai@gmail.com, Nov 24, 2006.

  1. Guest

    I am facing a issue while trying to load a library using
    System.loadLibrary

    Sample Code:

    public static void main(String[] args) {
    System.loadLibrary("xxx")

    }

    Throws the Exception:

    libxxx.so: undefined symbol: yyyyy

    The libxxx.so file is present in $LD_LIBRARY_PATH
    Platform: Red-Hat Linux
    JAVA version: 1.5

    The file yyyyy.o is contained in some other archive files. I do not
    want to include this .o in this library libxxx.so. How to tell JVM
    about the location of this .o (inside a .a file) while it loads the
    libxxx.so library

    Has anyone ever faced a similar problem, or has any clues regarding
    this problem as to how to fix this
     
    , Nov 24, 2006
    #1
    1. Advertisements

  2. On 23 Nov 2006 21:35:07 -0800, wrote:
    > libxxx.so: undefined symbol: yyyyy
    >
    > The libxxx.so file is present in $LD_LIBRARY_PATH
    > Platform: Red-Hat Linux
    > JAVA version: 1.5


    System.loadLibrary() didn't fail. It was your attempt to invoke the
    non-existing function that caused the exception.

    If the missing symbol is in libyyy.so then your libxxx.so is dependent
    on libyyy.so, and you need to specify that when you link libxxx.so,
    i.e.:

    gcc -shared -f libyyy.so x.o -o libxxx.so

    Also, libyyy.so must be in LD_LIBRARY_PATH at runtime.

    Use "readelf -d libxxx.so" to check that there is NEEDS entry
    mentioning libyyy.so. Use "ldd -v libxxx.so" to confirm that it can be
    resolved at runtime.

    /gordon

    --
    [ don't email me support questions or followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Nov 24, 2006
    #2
    1. Advertisements

  3. Nigel Wade Guest

    wrote:

    > I am facing a issue while trying to load a library using
    > System.loadLibrary
    >
    > Sample Code:
    >
    > public static void main(String[] args) {
    > System.loadLibrary("xxx")
    >
    > }
    >
    > Throws the Exception:
    >
    > libxxx.so: undefined symbol: yyyyy
    >
    > The libxxx.so file is present in $LD_LIBRARY_PATH
    > Platform: Red-Hat Linux
    > JAVA version: 1.5
    >
    > The file yyyyy.o is contained in some other archive files. I do not
    > want to include this .o in this library libxxx.so. How to tell JVM
    > about the location of this .o (inside a .a file) while it loads the
    > libxxx.so library
    >
    > Has anyone ever faced a similar problem, or has any clues regarding
    > this problem as to how to fix this


    Your criteria are mutually exclusive. You either link libxxx.so against the
    other archive (and include the object in libxxx.so) or you are doomed to
    failure.

    There is no way to make an executable retrieve an object from an archive file.
    The object must be included in the executable, or one of the DSOs it loads.
    Since there is no way to modify the java executable to include the object in
    that, your only choice is to include it in your DSO.

    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
     
    Nigel Wade, Nov 24, 2006
    #3
  4. varshasavant2002

    Joined:
    Nov 18, 2016
    Messages:
    4
    Likes Received:
    0
    Hello,

    I am also facing similar issue .

    Trying to migrate application from JBoss to tomcat8 .
    We are using a .so native lib for a specific functionality .

    Everytime this function is called we need to load .so file but it throws error :
    Native code library failed to load. java.lang.UnsatisfiedLinkError:

    I have tried multiple things
    1. set -Djava.library.path = XX folder path of native lib explicitly through tomcat VM argument
    2. copy xxx.so file to /usr/lib/ folder and give the -Djava.library.path= /usr/lib
    3. Also tried installing tomcat-APR and tomcat-Native libraries
    4. Tried to Load file using below line to check where native lib is getting loaded or not
    System.loadLibrary(so filename );

    5.Tried settign export LD_LIBRARY_PATH=/usr/local/apr/lib

    But NO LUCK :(:(

    Please someone help with this .
    Why my xxx.so file is not getting loaded


    -Varsha
     
    varshasavant2002, Nov 18, 2016
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.