Android NDK开发引用第三方库CMakeList.txt编译报错:
ninja: error: '/XXX/NDKApplication/app/src/main/cpp/src/main/cpp/armeabi-v7a/libavcodec.so',
needed by '/XXX/NDKApplication/app/build/intermediates/cmake/debug/obj/armeabi-v7a/libhf_code.so', missing and no known rule to make it
原因是CMakeList.txt 里的配置有误,我用的版本是3.10.2
原因一:文件路径或文件名配置错误
cmake_minimum_required(VERSION 3.10.2)
add_library( # Sets the name of the library.
hf_code
SHARED
native_test.cpp #这里路径或文件名配置有误
)
原因二:target_link_libraries 链接第三方库没有使用${}包起来
add_library( swscale-5
SHARED
IMPORTED)
set_target_properties( swscale-5
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/src/main/cpp/armeabi-v7a/libswscale.so)
target_link_libraries(
${swscale-5} #链接第三方库需要${}
${log-lib} )
附一份导入了FFmpeg库的完整CMakeList.txt
# For more in

最低0.47元/天 解锁文章
2591





