I recently encountered a project need to use cmake compiled .so library.When compiled with ndk-build, the size of .so library is 415k.When compiled with cmake , the size of .so library is 4.5M.
plugin for Gradle versio:gradle:3.0.0', gradle version: gradle-4.1-all.zip
build.gradle cmake configuration:
ndk {
abiFilters 'armeabi','armeabi-v7a','x86'
}
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-21',
'-DANDROID_TOOLCHAIN=clang',
'-DCMAKE_BUILD_TYPE=Release'
targets 'device'
}
}
CMakeLists.txt file is as follows:
cmake_minimum_required(VERSION 3.4.1)
set (CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE ON)
add_library(so SHARED IMPORTED)
set_target_properties(
so
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../jniLibs/${ANDROID_ABI}/so.so)
add_library(
myso
SHARED
XXX.cpp
.......
xxx.c
...
)
target_include_directories(myso PRIVATE
src
.....
)
find_library(
log-lib
log )
target_link_libraries(
myso
so
android
log
)
set(distribution_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../dis)
set_target_properties(myso
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
"${distribution_DIR}/lib/${ANDROID_ABI}")
I compare the symbols in two .so library files and found that the small .so library has 1000 lines, The same as the first 1000 lines of the big .so library, the larger ones have more symbols than the smaller ones. Is my cmake configuration wrong?