Linking/Deferred linking for binary packages
From Sidvind
libfoo.so may be distributed as a binary package and app.c foo.h would be distributed as source-code and built on the clients. libfoo.so has unresolved references which is resolved when building app on the client.
This helps with two problems:
- Library versions, if a library has changed its version number but the change is ABI compatible with libfoo.so a simple rebuild of app will resolve this (just as rebuilding source-based packages)
- Library path issues, some distributions place libraries in non-standard locations and maybe a dependency is installed by the user in their home-directory. This can also be fixed using symlinks or by fiddling with LD_LIBRARY_PATH but deferred linking is better in long term.
Code: app.c (view, download)
- #include "foo.h"
- int main(int argc, const char* argv[]){
- return real_main(argc, argv);
- }
Code: foo.h (view, download)
- #ifndef __FOO_H
- #define __FOO_H
- int real_main(int argc, const char* argv[]);
- #endif /* __FOO_H */
Code: foo.c (view, download)
- #include "foo.h"
- #include <stdio.h>
- #include <jpeglib.h>
- int real_main(int argc, const char* argv[]){
- printf("in real_main\n");
- struct jpeg_compress_struct cinfo;
- struct jpeg_error_mgr jerr;
- cinfo.err = jpeg_std_error(&jerr);
- jpeg_create_compress(&cinfo);
- return 0;
- }