Dear experts,
I've been building my static library which has approximately 160,000 lines of codes.
However, I've observed 2 things,
1) The debug library is almost 1 GB
2) The release library is 500MB+
I find these sizes very prohibiting and makes it very hard to distribute via the network.
Is there something wrong?
I'm using Visual Studio 2005 SP1. My project is a pure C/C++ static library project.
I use templates quite extensively, it takes up about 30-40% of code memory approximately (due to smart pointers, data structures, etc etc etc)
I wonder if there's any options that I can set to reduce the static library size, since moving away from templates is next to impossible.
Thanks!
Jeremy
(a) Most compilers have an option to optimize for size. For gcc eg. that's -Os, for VC++ that's /Os
(b) As you know, heavy use of templates can cause a lot of bloat in executable size. Wherever possible, consider minimizing the use of templates.
(c) Make sure to only link in that what you actually need (especially when it comes to external libraries).
(d) Consider splitting up the huge library in several smaller more focused libraries.
(e) Wherever possible, consider linking dynamically instead of statically.
(f) if you have any data in the binary, consider moving it out of the library into separate files, and load the data from those files.