AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only

Dependant library not loaded in AIX

  • 1.  Dependant library not loaded in AIX

    Posted Wed September 24, 2008 01:10 AM

    Originally posted by: SystemAdmin


    Hi,
    The problem statement:

    Problem with loading a dependant shared object while loading the parent shared object.

    Description:

    My project has a java module. At runtime this java module loads a JNI shared object(libJNIApi.so).This JNI shared object is dependant on a CPP shared object (libV5Capi.so). Both objects reside in the same directory under installation directory. But the installation directory is not pre defined and can be anywhere on the system.

    When libJNIApi.so is loaded through java call System.load("InstallPath/lib/libJNIApi.so"), it also tries to load the libV5Capi.so.
    This works fine when the java is invoked from the directory where the libraries are present. But when java is run from a different loaction, the load fails.

    The error during this load is

    java.lang.UnsatisfiedLinkError: /home/chikkall/test//lib/libJNIApi.so (JVMPORT003E Dependent module libV5Capi.so could not be loaded)
    at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:952)
    at java.lang.System.load(System.java:440)
    at com.ov.lic.sm.Init.init(Init.java:154)
    at com.ov.lic.sm.ConfigManager.init(ConfigManager.java:194)
    at com.ov.lic.sm.ConfigManager.initialize(ConfigManager.java:245)
    at com.ov.lic.sm.ConfigManager.initialize(ConfigManager.java:259)
    at com.ov.lic.sm.ConfigManager.initSecurityModule(ConfigManager.java:170)
    at com.ov.lic.sm.ConfigManager.InitializePath(ConfigManager.java:87)
    at com.ov.lic.sm.SecurityModule.InitializePath(SecurityModule.java:59)
    at JDemoUtility.initPath(JDemoUtility.java:83)
    at JDemoUtility.main(JDemoUtility.java:938)
    libJNIApi.so is searching for the libV5Capi.so in the current working directory and fails to find it.
    Options we considered:

    1. Load the dependent shared object(libV5Capi.so) explicitly in java module before loading the parent shared object(libJNIApi.so).
    2. Use $ORIGIN in the runtime path of libJNIApi.so, which gets resolved to the absolute path of libNIApi.so at runtime.

    Both options work for all unix flavors. But on AIX, For option 1: The parent library still tries to load the dependent library, even if it is loaded.
    For option 2: $ORIGIN option is not available(couldn't find in the linker n loader manuals)

    Build details:


    The libJNIApi.so is built in the make file as

    SHRD=/usr/XLC/usr/vacpp/bin/makeC++SharedLib_r
    SHRD_OBJ= -p -8192 -bM:SRE -bnoquiet -bnoentry -lc

    libJNIApi.so: libV5Capi.so JNIApi.o
    $(SHRD) -G $(SHRD_OBJ) -L. -lV5Capi -o $@ $?
    Dump of libJNIApi.so

    $ dump -Hv libNIApi.so

    libJNIApi.so:

    ***Loader Section***
    Loader Header Information
    VERSION# #SYMtableENT #RELOCent LENidSTR
    0x00000001 0x00000050 0x000000b4 0x0000005c

    #IMPfilID OFFidSTR LENstrTBL OFFstrTBL
    0x00000003 0x00001010 0x00000cd4 0x0000106c
    ***Import File Strings***
    INDEX PATH BASE MEMBER
    0 .:/usr/XLC/usr/vacpp/lib:/usr/lib/threads:/usr/lib:/lib
    1 libc.a shr.o
    2 libV5Capi.so

    Thanks,
    Yashu