How To Link .a To .so And Create New .so For Android
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
Solution 1:
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:
- Lay your prebuilt libraries in such order:
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
- Add paths to APPEND CMAKE_FIND_ROOT_PATH in your project .so:
list(APPEND CMAKE_FIND_ROOT_PATH libs/${ANDROID_PLATFORM}/${ANDROID_ABI}/existing)
list(APPEND CMAKE_FIND_ROOT_PATH libs/${ANDROID_PLATFORM}/${ANDROID_ABI}/my)
- Now you can use them from your project .so:
find_library(existing_lib existing)
find_library(my_lib my)
add_library(project SHARED <source_files>)
target_link_libraries(project existing_lib my_lib)
Post a Comment for "How To Link .a To .so And Create New .so For Android"