I am currently trying to compile all my applications' dependencies as a static library. My motivation:
- Not to rely on any OS provided libraries in order to have a perfectly reproducible code base
- Avoid issues when deploying on other systems caused by dynamic linking
- Avoid run-time clashes when linking against different versions of a library
- Being able to cross-compile for other OS
However, as I initially dreaded I had to go down the rabbit hole quite fast. I am currently stuck with OpenCV and I'm sure there is more to come. However, my main questions are:
- Is it possible to build an entirely statically build app (e.g. libc, ligcc, etc. ?)
- Is it possible to link all libraries statically but link major components (libgcc, etc.) dynamically?
- If not, is it possible to link against statically built libraries (e.g. OpenCV) but to satisfy their dependencies by linking dynamically (zlib, libc, etc.)?
- I did research on the internet but couldn't find a comprehensive guide that dwells on the internals of linking (static vs. dynamic). Do you know about a good book / tutorial? Does a book about gcc get me further?
- Is this a very stupid idea?