Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. avoid loading an already loaded shared library

avoid loading an already loaded shared library

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yashusid
    wrote on last edited by
    #1

    Hi, I have one JNI shared libray which depends on a CPP library. In my module loading CPP shared library first and loading JNI library, eventhough the dependant library is loaded JNI library tries to load CPP shared library. Please let me know how to avoid loading an already loaded shared library .... Thanks, Yashu

    A 1 Reply Last reply
    0
    • Y Yashusid

      Hi, I have one JNI shared libray which depends on a CPP library. In my module loading CPP shared library first and loading JNI library, eventhough the dependant library is loaded JNI library tries to load CPP shared library. Please let me know how to avoid loading an already loaded shared library .... Thanks, Yashu

      A Offline
      A Offline
      Abhishek Srivastava
      wrote on last edited by
      #2

      Hi, Details needed ! 1) What problem are you facing if you are again loading the already loaded library.Asd i dont see any issue with that. 2) Are you loading these .dll's explicitly or implicityly i.e.using LoadLibrary or directlinking to it? As in case of explicit linking your process must have the Lib handle to call its function. Regards, Abhishek

      Abhishek Srivastava Technical Lead. India.

      Y 1 Reply Last reply
      0
      • A Abhishek Srivastava

        Hi, Details needed ! 1) What problem are you facing if you are again loading the already loaded library.Asd i dont see any issue with that. 2) Are you loading these .dll's explicitly or implicityly i.e.using LoadLibrary or directlinking to it? As in case of explicit linking your process must have the Lib handle to call its function. Regards, Abhishek

        Abhishek Srivastava Technical Lead. India.

        Y Offline
        Y Offline
        Yashusid
        wrote on last edited by
        #3

        Please find my problem in datail... 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: --------------------------------

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups