开发者

Size of Cocoa application based on Boost

What I need:

  • wrap boost-based C++ library into Objective-C++;
  • create Cocoa app using that Objective-C++ library.

What I have:

  • builded boost 1.46.1 (dynamic .dylib and static .a variants);
  • Xcode project of C++ library (boost-based, wrapped in Objective-C);
  • Xcode project of the final application with library linked as subproject (app target is dependent on library).

My questions:

  1. When I build application the result binary is of 15~20 MB, but intermediate library is of 100 MB. How can this be explained?
  2. The final application (in any variant) when ran uses boost libs from system folder (I see this in the Activity Monitor, in Process Info > Open Files and Ports). How can this be avoided? O开发者_StackOverflowr how to build completely standalone, libs-and-frameworks-independent application?

Some more details:

  • I've tried to link to library both .dylib's and .a's variants — intermediate lib is 100 MB, app is 15 MB;
  • I've tried to use .framework instead of static library .a — framework is 15 MB, app with framework is 30 MB;
  • I've tried to build pure C++ commandline application (functionally equivalent to Objective-C app + library) — binary size is 15 MB;
  • library uses only part of boost (filesysytem, iostream, program_options, system, threads) + few system dylibs;
  • I use Xcode 4.2, Mac OS X 10.6 SDK, x86_64 variant;
  • tested with LLVM GCC 4.2, Apple LLVM 3.0, GCC 4.2 compilers;
  • tested with Strip Debug Symbols YES and NO, Dead Code Stripping YES and NO, Generate Debug Symbols YES and NO, Optimization Level -O0 and -Os, Inline Methods Hidden YES and NO, Symbols Hidden by Default YES and NO.


to know what libraries your app depends on, you can use otool -L yourCocoaApp. It will list dependencies of your app and their full paths. You can also install the captainmaclib application.

To make your app use specific version of a lib, you should adjust the paths of its dependencies. You can do it using the install_name_tool command line tool or using the dylibbundler app from the site above. There also is tools included in CMake to do it. It may exists tools inside XCode but I'm not using it so I don't know.

Hope this help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜