Reputation: 1039
I have an existing android project where a .so (say existing.so) is packaged and loaded in some .aar (say existing.aar). That existing.so file exposed a symbol(funcion) which my .a (my.a) static library will use. How to include my.a file in that particular project so that it get links to existing.so ? Should a new .so made linking my.a and existing.so ? I can add cmake or ndk dependency in that existing project.
Upvotes: 0
Views: 938
Reputation: 1413
If the native prebuilt libraries are provided via the .aar prefab, here's a link from Android Developers of how to do it, if not, you need to do it like you would for a normal CMake project:
libs/${ANDROID_PLATFORM}/${ANDROID_ABI}/existing
libs/${ANDROID_PLATFORM}/${ANDROID_ABI}/my
e.g.:
libs/android-28/x86_64/existing/lib/existing.so
libs/android-28/x86_64/existing/include/existing.h
libs/android-28/x86_64/my/lib/my.a
libs/android-28/x86_64/my/include/my.h
list(APPEND CMAKE_FIND_ROOT_PATH libs/${ANDROID_PLATFORM}/${ANDROID_ABI}/existing)
list(APPEND CMAKE_FIND_ROOT_PATH libs/${ANDROID_PLATFORM}/${ANDROID_ABI}/my)
find_library(existing_lib existing)
find_library(my_lib my)
add_library(project SHARED <source_files>)
target_link_libraries(project existing_lib my_lib)
Upvotes: 2