Linking/Deferred linking for binary packages

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:
 * 1) 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)
 * 2) 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.


 * 1) include "foo.h"

int main(int argc, const char* argv[]){ return real_main(argc, argv); }


 * 1) ifndef __FOO_H
 * 2) define __FOO_H

int real_main(int argc, const char* argv[]);


 * 1) endif /* __FOO_H */


 * 1) include "foo.h"
 * 2) include 
 * 3) include 

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; }

 all: app

libfoo.so: CFLAGS+=-fPIC

libfoo.so: foo.o	$(CC) -shared $(LDFLAGS) foo.o -o libfoo.so

app: app.o libfoo.so $(CC) $(LDFLAGS) app.o -Wl,-rpath,. -L. -lfoo -ljpeg -o app

%.o : %.c	$(CC) -Wall $(CFLAGS) -c $< -o $@

clean: rm -rf *.so *.o app