Operating Systems - (Native) Libraries

About

native library are object file (binary) that has been compiled to the target operating system

They can be used as libary in a application

There is two types of OS library:

See shared vs static

Interface

A native interface is an interface that permits to call native library as a normal library.

Example:

  • Java: JNI. See also: Preset for interface to C/C++ library with JNI.
  • http://www.swig.org: SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl.

Shared vs Static

Memory Footprint

  • Shared libraries can be used by any application software on the system without loading multiple copies into memory.
  • Static libraries copy the code directly into the application therefore growing every application by the size of all the libraries they use.

In most modern Unix-like systems, including Linux, programs are by default compiled to use shared library (so, dll)

Code versioning

  • Shared libraries have no built-in mechanism for backward compatibility. Minor changes may cause the application to crash.
  • Static libraries avoid this problem because the version that was used to build the application is included inside it, so even if a newer version exists elsewhere on the system, this does not affect the application.

Powered by ComboStrap