In the following snippet from the Google tutorial 'Add C and C++ Code to Your Project'
In the section 'Add other prebuilt libraries'
add_library(...)
set_target_properties( # Specifies the target library.
imported-lib
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
imported-lib/src/${ANDROID_ABI}/libimported-lib.so )
source: https://developer.android.com/studio/projects/add-native-code.html
What is the implicit root directory associated with imported-lib/src/${ANDROID_ABI}/libimported-lib.so
?
My 1st guess was that it was project/app/
i.e. the directory where CMakeLists.txt
resides, but experimentation suggests this is not the case. I get link errors saying the functions in the shared library cannot be found when I make this assumption.
Update:
Further to Tsyvarev s help I've realised the error is not from set_target_properties()
but target_link_libraries()
set_target_properties()
does seem to use project/app
as its root
but target_link_libraries()
doesn't. If I assume project/app
as the root for my prebuilt shared library location then my project build fails. If I specify the full path, i.e. from /home/me/...etc./etc./mylib.so
then it does work.
The error message in the 1st instance is:
/home/me/Android/Sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -llibs/armeabi-v7a/libmylib.so
maybe the root dir in this instance is that in which ld
is located?