1

I'm trying to reduce the size of files in my project to reduce its overall size. One of the ways I'm looking at is replacing some of the static libraries the files are made of with a dependency on shared objects. Before I start doing that, I'd like to see how much space every static library is taking in my files. Is there a way to get a breakdown of a file that shows how much of it is actually a static library it is linked with?

nitzanms
  • 1,786
  • 12
  • 35
  • 1
    I'm not sure, but static libraries are 'like' normal code for the linker. So there shouldn't be any big overhead. It is like a bunch of big cpp files. Dynamic libraries are different though... – pearcoding Nov 03 '13 at 11:29
  • `nm -S --size-sort file.exe` – bobah Nov 03 '13 at 11:30
  • 1
    @omercan1993 - static libraries are archives of object file and are treated as such by the linker – bobah Nov 03 '13 at 11:31
  • @bobah - That was what I was trying to say :D thanks :D – pearcoding Nov 03 '13 at 11:32
  • @bobah, that's a good start, thanks. But here I get a breakdown per symbol, I think, and it's a bit difficult to tell where each static library starts and ends. – nitzanms Nov 03 '13 at 12:10
  • @omercan1993 the idea is that I have many files in my project that include the same static library over and over again. I'm trying to estimate how much I could reduce from the project's space by using dynamic libraries instead. – nitzanms Nov 03 '13 at 12:10
  • @nitzanms A intelligent Linker, like the VC or the GCC one, will just include the library once in the project, except when you do a nested library library linking, then there could be some duplications, as far as I know. By using a dynamic library you will get a performance overhead but if that little performance loss is not a problem, you will get a system wide unique library, except the data area. So use dynamic libraries instead if you can. – pearcoding Nov 03 '13 at 12:42
  • @omercan1993 , the project has many plug-in like files. You can only load one of them in the project at a time, so library duplication isn't really an issue. The most significant static library the files link to will probably stay static because of reasons ( :) ), so I'm trying to figure out whether it's worth the trouble to make the other libraries dynamic. – nitzanms Nov 04 '13 at 09:00
  • @nitzanms I think it would be worth due to the 'complex' library interactions. – pearcoding Nov 04 '13 at 10:51

0 Answers0