Much larger static library generated by xcode

99封情书 提交于 2019-12-24 14:59:41

问题


I have a C++ project which is compiled to a universal shared library. Now, I also want a static library for the same. When I reuse the shared library Xcode project to create static library, the size of static library created is much smaller (~ 3MB) as compared to when I create a separate Xcode Static Library project to compile my code (~19 MB). (universal - 32 & 64 bit)

Here is what I tried with the shared library project:

xcodebuild -project MyLibrary.xcodeproj build MACH_O_TYPE=staticlib EXECUTABLE_EXTENSION=a GCC_ENABLE_SYMBOL_SEPARATION=NO PACKAGE_TYPE=com.apple.package-type.static-library

Both the libraries work fine when linked to any C++ project. otool gives same output for both libraries

Also, I tried creating the static build using Qt Creator and again the library size was around 3 MB (32 + 64 bit)

I wonder what is the difference between the two static libraries if they both link fine.

The size of the same static library when compiled on Linux is aroung ~4MB (32 + 64 bit)

来源:https://stackoverflow.com/questions/31770110/much-larger-static-library-generated-by-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!