0

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

3
  • Did you copy the .so into the src/main/jniLibs/live555/lib/armeabi-v7a directory? Commented Oct 5, 2018 at 12:31
  • Yes i did. If I change " ${PROJECT_SOURCE_DIR}" to absolute path it accepts otherwise gives that error. So I wonder if I have to use a system path like /usr/local... ? Commented Oct 5, 2018 at 13:02
  • Use message(STATUS ${PROJECT_SRC_DIR}) before set_target_propeties, then try to get the property after set to check it : stackoverflow.com/questions/24881408/… Commented Oct 5, 2018 at 13:20

1 Answer 1

3

${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) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.