Reputation: 97
I am trying to link live555.so and .h files with an Android project using cMake. If i don't use absolute path i'm getting error.
My cMake file:
cmake_minimum_required(VERSION 3.4.1)
include_directories( ${PROJECT_SOURCE_DIR}/src/main/jniLibs/live555/include )
add_library( live555 SHARED IMPORTED )
set_target_properties( live555 PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/src/main/jniLibs/live555/lib/${ANDROID_ABI}/live555.so)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp )
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
target_link_libraries( # Specifies the target library.
native-lib
android
live555
${log-lib} )
And error:
Error:error: '../../../../src/main/jniLibs/live555/lib/armeabi-v7a/live555.so', needed by '../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so', missing and no known rule to make it
Upvotes: 0
Views: 4052
Reputation: 57203
${PROJECT_SOURCE_DIR}
is the directory where the main CMakeList.txt file resides. That's typically app/src/main/cpp. You can work out the correct relative path now.
This means that you can simply write
include_directories( ${PROJECT_SOURCE_DIR}/../jniLibs/live555/include )
add_library( live555 SHARED IMPORTED )
set_target_properties( live555 PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/live555/lib/${ANDROID_ABI}/live555.so)
Upvotes: 3