'How can I inspect DYLIB contents in terms of size?

After moving from a manually created Xcode project to a CMake-generated Xcode C++ project, my compiled binary DYLIB size has grown significantly: from about 35 MB to about 53 MB.

All the compilation and linking settings I could compare in Xcode projects look pretty much the same (including vs. not including debug symbols, optimization levels, etc.). I wonder if there are any tools to inspect DYLIB contents - what occupies size in the first place.



Solution 1:[1]

how to compare in #if condition of preprocessor for string

It is not possible to compare strings in preprocessor.


You can add something unique to r8 to make it longer and define it to a number. You could just #define r8 1, but r8 is a bit short and could be break random code.

// #define ML_ARCH   r8

#define ARCH_r8               1
#define ARCH_some_other_arch  2
#define ARCH_etc              3

#define XADD_ARCH(a) ARCH_##a
#define ADD_ARCH(a)  XADD_ARCH(a)    
#define IS_ARCH(a)   (ADD_ARCH(ML_ARCH) == ARCH_##a)

// #if XCONCAT(ARCH_, ML_ARCH) == ARCH_r8
#if IS_ARCH(r8)

Overall, consider doing -D ML_ARCH=ARCH_r8 and then just #if ML_ARCH == ARCH_r8.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KamilCuk