c++ - What is the difference between .o .a and .so files? -


i know .o object files, .a static libraries , .so dynamic libraries? physical significance? when can use , when not?

.a "archive". although archive can contain type of file, in context of gnu toolchain, library of object files (other toolchains on windows use .lib same purpose, format of these not typically general purpose archive, , specific toolchain). possible extract individual object files archive linker when uses library.

.o object file. code compiled machine code not (typically) linked - may have unresolved references symbols defined in other object files (in library or individually) generated separate compilation. object files contain meta-data support linking other modules, , optionally source-level symbolic debugging (in gdb example). other toolchains, again typically on windows, use extension .obj rather .o.

.so shared object library (or shared library). dynamically linked executable when program launched rather statically linked @ build time. allows smaller executables, , single object library instance used multiple executables. operating system apis typically shared libraries, , used in gnu licensing reasons separate lgpl code closed-source proprietary code example (i not lawyer - making no claims regarding legitimacy of approach in particular situation). unlike .o or .a files, .so files used application must available on runtime system. other systems (again typically windows) use .dll (dynamic link library) same purpose.

it perhaps useful understand .o files linked before object code in .a files such if symbol resolution satisfied .o file, library implementation not linked - allowing replace library implementations own, , library implementations call user-defined code - example gui framework might call application entry-point.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -