How to add external library in android studio with cmake?

后端 未结 1 1888
感情败类
感情败类 2021-01-17 00:57

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:

1条回答
  •  一生所求
    2021-01-17 01:54

    ${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)
    

    0 讨论(0)
提交回复
热议问题