A native shared library is a compiled code library that’s designed to be used by multiple programs and is written in a language like C or C++. These libraries are platform-specific and typically have extensions like .so (Linux/Android), .dll (Windows), or .dylib (macOS).
Here’s the breakdown:
- “Native” means it’s compiled to run directly on the operating system’s hardware, not inside a virtual machine like Java or .NET.
- “Shared” means multiple programs can load and use the same library at runtime, which saves memory and promotes modular design.
In Android, for example, native shared libraries are often used to boost performance or access low-level system features. They’re loaded using the Java Native Interface (JNI), and apps must declare them properly to avoid conflicts or security issues.
If you're working with Java and want to create a native shared library from your code, tools like GraalVM let you compile Java classes into native .so libraries that can be called from C or other native code.