I am trying to build a shared library on mac (a .bundle file) so that I can use it via js-ctypes in my firefox addon. Because jsctypes has a restriction on using only c (and a small subset of c++) I have created a static library and linking it to create a bundle. The issue is, the bundle that I create, happens to be too big (~8MB) - I am not sure how to strip it down so that all unused functions/symbols are removed.
I tried adding a -s option - but that didnt do much - it brought down the size from 8.3 to 8 mb.
I also tried -Wl,--gc-sections - but I get some error - saying that is not a recognized option.
Here is how I am building the .bundle file:
$ gcc -O -fno-common -c -ansi -fdata-sections -ffunction-sections thumb.c -arch i386 -arch x86_64
$ gcc -flat_namespace -bundle -s -Os -o libThumbnailCreator.bundle thumb.o -L. -lThumbnailCreator_static -lstdc++ -arch i386 -arch x86_64
I get the libThumbnailCreator_static.a file (the static library) to the directory from where I compile this. Also, please note the static library is targetting both i386 arch and x86_64 arch. The size of the static lib is ~16MB
Can someone tell me - if I am doing something wrong?
I have compiled the same code on windows - and my resultant dll is much less in size ~1.2MB
Thanks Kapil
I tried adding a -s option - but that didnt do much - it brought down the size from 8.3 to 8 mb.
I also tried -Wl,--gc-sections - but I get some error - saying that is not a recognized option.
Here is how I am building the .bundle file:
$ gcc -O -fno-common -c -ansi -fdata-sections -ffunction-sections thumb.c -arch i386 -arch x86_64
$ gcc -flat_namespace -bundle -s -Os -o libThumbnailCreator.bundle thumb.o -L. -lThumbnailCreator_static -lstdc++ -arch i386 -arch x86_64
I get the libThumbnailCreator_static.a file (the static library) to the directory from where I compile this. Also, please note the static library is targetting both i386 arch and x86_64 arch. The size of the static lib is ~16MB
Can someone tell me - if I am doing something wrong?
I have compiled the same code on windows - and my resultant dll is much less in size ~1.2MB
Thanks Kapil