How to work with static and dynamic libraries using libtool/autoconf only.
Both static and dynamic libraries can be built by libtool and are always stored in the ~/.libs subdirectory.
The following methods show how to building different types of libraries using libtool.
-
Basic library locations
-
how to build the standalone library.
-
how executable uses those libraries.
-
how a library can include another library.
-
how to build a dynamic-LINK library for use with dynamic loader (dlopen) API.
Method name ending with 's' (ie. MethodXs) are static/archive library approaches.
Method name ending with 'd' (ie. MethodXd) are dynamic library approaches.
How to place various output files into different locations.
-
Library and object files into default library directory (
./.libs
) -
Object files into same source directory
-
Library into same source directory
Library and object files into default library directory (./.libs
)
Object files into same source directory
Library into same source directory
Method 2 is how to build the shared-object/archive library using libtool.
- Library filetype ends with '.a'.
- Static-linked of all object files into an archive library.
- Archive library does get installed but 'make install' can.
- Archive library does NOT get packaged but 'make dist' can.
Build a standalone dynamic library.
- Library filetype ends with '.so'.
- Dynamic library is also known as a library of shared objects.
- Shared object library are more frequently called dynamic library.
- PIC-compiled of all object files into a shared object (.so) library.
- Dynamic library does get installed but 'make install' can.
- Dynamic library does NOT get packaged but 'make dist' can.
Method 3 is making a library be used immediately by an executable file using libtool.
Create an executable that includes a static library.
Create an executable that includes a shared-object/dynamic library.
Method 4 is making a library referenced by another library then used by an executable file using libtool.
Method 5 is making a library be used but later dynamically loaded by an executable file using libtool.
References: