我正在尝试构建并使用适用于Android的ffmpeg。我的Andoid Studio版本是2.2.2,ffmpeg版本是3.2。按照Android文档中有关导入重构库的说明,我认为我已经正确设置了,但仍然不断出现此错误。
ninja: error: 'avcodec-NOTFOUND', needed by '../../../../build/intermediates/cmake/debug/obj/armeabi-v7a/...
这是设置。
add_library( avcodec SHARED IMPORTED )
add_library( avdevice SHARED IMPORTED )
add_library( avfilter SHARED IMPORTED )
add_library( avformat SHARED IMPORTED )
add_library( avutil SHARED IMPORTED )
add_library( swscale SHARED IMPORTED )
set_target_properties( avcodec
PROPERTIES FFMPEG_LIB_IMPORTED_LOCATION
libs/ffmpeg/${ANDROID_ABI}/lib/libavcodec.so
)
set_target_properties( avdevice
PROPERTIES FFMPEG_LIB_IMPORTED_LOCATION
libs/ffmpeg/${ANDROID_ABI}/lib/libavdevice.so
)
set_target_properties( avfilter
PROPERTIES FFMPEG_LIB_IMPORTED_LOCATION
libs/ffmpeg/${ANDROID_ABI}/lib/libavfilter.so
)
set_target_properties( avformat
PROPERTIES FFMPEG_LIB_IMPORTED_LOCATION
libs/ffmpeg/${ANDROID_ABI}/lib/libavformat.so
)
set_target_properties( avutil
PROPERTIES FFMPEG_LIB_IMPORTED_LOCATION
libs/ffmpeg/${ANDROID_ABI}/lib/libavutil.so
)
set_target_properties( swscale
PROPERTIES FFMPEG_LIB_IMPORTED_LOCATION
libs/ffmpeg/${ANDROID_ABI}/lib/libswscale.so
)
# Specifies a path to native header files.
include_directories(
libs/ffmpeg/${ANDROID_ABI}/include
)
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
avcodec avdevice avfilter avformat avutil swscale
${log-lib}
)
如果我指定完整的库名称,例如libavcodec.so...,错误将会消失。
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
libavcodec.so libavdevice.so libavfilter.so libavformat.so libavutil.so libswscale.so
${log-lib}
)
我想知道是否有人遇到了类似的问题或者知道为什么编译会出现这种情况。
find_library
搜索库失败时,通常会产生值为*-NOTFOUND
。因为您的代码没有使用此函数,所以看起来其他一些代码尝试迭代链接到native-lib
中的库并搜索它们。顺便说一下,您导入的某些库位于lib/
下,而其他库位于libs/
下。这是有意为之吗?另外,avfilter
库使用${ANDROID_ABI}lib
路径组件,而其他库使用${ANDROID_ABI}/lib
。 - TsyvarevFFMPEG_LIB_
前缀)。此外,此属性的值应为绝对路径。 - Tsyvarev