victor-paltz / global-load-library Goto Github PK
View Code? Open in Web Editor NEWA magic function that loads .so libraries with the RTLD_GLOBAL flag. It is especially useful when working with JNI libraries dependencies.
License: MIT License
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
(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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.