aliyun / aliyun-oss-cpp-sdk

Aliyun OSS SDK for C++
Other
188 stars 88 forks source link

为什么目标安卓打包出来的静态库特别大 #84

Closed weizhoufeng closed 4 years ago

weizhoufeng commented 4 years ago

目标安卓打包出来的静态库是目标Mac打出来的5倍大,解压静态库取出相同一个.o对比,elf 格式比 mach-o 大5倍

在Mac 上打包,采用Mac 系统打包方式

cmake -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl@1.1/1.1.1g \ -DOPENSSL_LIBRARIES=/usr/local/Cellar/openssl@1.1/1.1.1g/lib \ -DOPENSSL_INCLUDE_DIRS=/usr/local/Cellar/openssl@1.1/1.1.1g/include/ .. make

打包出来19MB

给安卓打包

cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \ -DANDROID_NDK=$ANDROID_NDK \ -DANDROID_ABI=arm64-v8a \ -DANDROID_TOOLCHAIN=clang \ -DANDROID_PLATFORM=android-23 \ -DANDROID_STL=c++_shared .. make

打包出来有104MB,用gstrip 去掉debug info之后还有46MB

huiguangjun commented 4 years ago

1) 通过 cmake 构建时, 可以增加如下参数.

-DCMAKE_BUILD_TYPE=XXX
Debug # Setup for easy debugging. No optimizations. DebugOpt # An optimized version of Debug. Release # Fully optimized, no debugging information. RelWithDebInfo # A debuggable version of Release. MinSizeRel # Like Release, but optimized for memory rather than speed.

2) 还可以增加一些 选项, 禁用部分功能

OSS_DISABLE_BUCKET (Default OFF) If turned ON, the SDK is built without the bucket's API. cmake .. -DOSS_DISABLE_BUCKET=ON

OSS_DISABLE_LIVECHANNEL (Default OFF) If turned ON, the SDK is built without the livechannel's API. cmake .. -DOSS_DISABLE_LIVECHANNEL=ON

OSS_DISABLE_RESUAMABLE (Default OFF) If turned ON, the SDK is built without the resumable operation feature. cmake .. -DOSS_DISABLE_RESUAMABLE=ON

OSS_DISABLE_ENCRYPTION (Default OFF) If turned ON, the SDK is built without the client-side encryption feature. cmake .. -DOSS_DISABLE_ENCRYPTION=ON