1

I'm developing a cross-platform static C++ library and am wondering if there are any build flags for reducing the size of the final MyLib.lib and libMyLib.a files on each platform (iOS, Android, Windows)?

I understand that every single dependency gets pulled into the build process and this is where my file size is coming from.

Why is my static library so huge?

But shouldn't there be some way to have the Linker/Librarian remove code from MyLib based on dependency calls actually made rather than theoretically possible?

The Linker does this when building the final .EXEcutable, but it seems the same rules could apply at the library linking level.

Overall this is a big problem for me because my cross-platform library is around 500MB for Windows and around 200MB on iOS. Oddly, Android is a reasonable 3.5MB.

Community
  • 1
  • 1
Bungles
  • 1,969
  • 2
  • 25
  • 54
  • 1
    Could the extra size be debug symbols? Try turning generate debug symbols off if set? – Rory McKinnel Jul 21 '15 at 21:25
  • It's a Release Mode compile (at least on Windows), so there shouldn't be any debug information. – Bungles Jul 21 '15 at 22:28
  • Are you using a lot of stl ? – ravindu1024 Jul 23 '15 at 10:12
  • It does seem you either have lots of extra symbols in your built files or more .o files/code in your archive library than on Android. I would have thought Android and iOS would be similar in size. Windows I could believe would be different. You could try using the `strip` command on iOS at least. – Rory McKinnel Jul 23 '15 at 11:50
  • Yes, I use a lot of C++11 features that come from STL & Boost. – Bungles Jul 23 '15 at 16:20
  • Using "strip libMyLib.a" didn't do much. Setting the Xcode build parameters to do stripping even in Debug mode also did nothing to change the .a size. – Bungles Jul 23 '15 at 21:45

0 Answers0