Why should I recompile the entire program only to update the library?

Regarding the following link: http://www.archlinux.org/news/libpnglibtiff-rebuilds-move-from-testing/

Can someone explain to me why the program should be restored after updating one of its libraries?

How does this make sense since the "main" file does not change at all?

+8
source share
3 answers

If the signatures of the functions involved have not changed, then the "rebuilding" of the program means that the object files must be linked again. You will not need to compile them again.

An API is a contract that describes an interface for public functions in a library. When the compiler generates code, it needs to know what type of variables will be passed to each function and in what order. He also needs to know the type of return, so he knows the size and format of the data that will be returned from the function. When your code is compiled, the address of the library function can be represented as "the beginning of the library plus 140 bytes." The compiler does not know the absolute address, so it simply indicates the offset from the beginning of the library.

But inside the library, the contents (i.e. implementation) of functions may change. When this happens, the code length may change, so the addresses of functions may change. It is the task of the linker to understand where the entry points of each function are and fill in these addresses in the object code to create an executable file.

On the other hand, if the data structures in the library have changed, and the library requires callers to manage the memory (bad practice, but unfortunately shared), you will need to recompile the code so that it can account for changes. For example, if your code uses malloc(sizeof(dataStructure)) to allocate memory for the library data structure doubled in size, you need to recompile the code because sizeof(dataStructure) will have a larger value.

+14
source

There are two types of compatibility: API and ABI.

Interoperability APIs are functions and data structures that other programs can rely on. For example, if version 0.1 of libfoo defines an API function called "hello_world ()" and version 0.2 removes it, any programs that depend on "hello_world ()" need to be updated to work with the new version of libfoo.

ABI compatibility is assumptions about how functions and, in particular, data structures are represented in binary files. If, for example, libfoo 0.1 also defined a recipe data structure with two fields: “instructions” and “ingredients”, and libfoo 0.2 introduces “dimensions” before the “ingredients” field, then programs based on libfoo 0.1 recipes should be recompiled , the instructions "and" ingredients "are likely to be at different positions in the version of libfoo.so version 0.2.

+5
source

What is a library?

If the "library" is only a binary file (for example, aka dynamically linked library ".dll", ".dylib" or ".so" or aka statically linked library ".lib" or ".a") then there is no need recompile, re-binding should be enough (and even this can be avoided in some special cases)

On the other hand, libraries often consist not only of a binary object - for example, header files may include some built-in (or macro) logic. if so, reconnecting is not enough, and you may need to recompile to use the latest version of lib.

+1
source

All Articles