【发布时间】:2018-10-05 12:18:43
【问题描述】:
我正在尝试使用 cMake 将 live555.so 和 .h 文件与 Android 项目链接。如果我不使用绝对路径,就会出错。
我的 cMake 文件:
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} )
还有错误:
错误:错误: '../../../../src/main/jniLibs/live555/lib/armeabi-v7a/live555.so', 需要 '../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so', 丢失并且没有已知的规则来制作它
【问题讨论】:
-
您是否将.so 复制到
src/main/jniLibs/live555/lib/armeabi-v7a目录中? -
是的,我做到了。如果我将“ ${PROJECT_SOURCE_DIR}”更改为绝对路径,则它接受否则会给出该错误。所以我想知道我是否必须使用像 /usr/local... 这样的系统路径?
-
在set_target_propeties之前使用
message(STATUS ${PROJECT_SRC_DIR}),然后尝试获取set后的属性进行检查:stackoverflow.com/questions/24881408/…
标签: android cmake android-ndk