Coder Social home page Coder Social logo

victor-paltz / global-load-library Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 29 KB

A magic function that loads .so libraries with the RTLD_GLOBAL flag. It is especially useful when working with JNI libraries dependencies.

License: MIT License

Dockerfile 3.48% Makefile 4.27% C++ 15.64% Java 76.61%

global-load-library's People

Contributors

victor-paltz avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

global-load-library's Issues

Need to load library twice?

(Please excuse my rather naive understanding of both Linux dynamic loading and JNI).

In my use case, I have two shared libraries, libA.so and libB.so, where the code in B calls a function defined in A, and where B contains "native" functions to be called from Java via JNI.

As per my incorrect intuition, I was expecting java.lang.System.load(libA.so) to make the symbols defined in A available to the code in B, but that wasn't the case. If I use LibraryLoaderJNI.loadLibrary(libA.so), as expected, the symbols in A are defined when being called from B.

However, if I attempt to access the functions in A directly from Java, I get an UnsatisfiedLinkError. To get around this, I found that I need to call both LibraryLoaderJNI.loadLibrary(libA.so) (to make it available to B) and then System.load(libA.so) (to make it available to Java).

Is this expected behavior? Is this a result of calling dlopen with the RTLD_LAZY flag? If so, could a this library be extended to allow one to specify if it should be LAZY or NOW?

[Note that I'm loading A and B from within a jar file, using the same NativeUtils approach that you are using to load libnativeload.so - which means, as far as I can tell, that the two "copies" of A loaded are independent - not sure if this is relevant to my success or not].

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.