CMake undefined reference to 问题

Simples/app/src/main/cpp/../../../../ffmpeg-3.3.3/build/android/arm64-v8a/lib/libavcodec.a(utils.o): In function `avcodec_string':
Simples/ffmpeg-3.3.3/ libavcodec/utils.c:3239: undefined reference to ` av_get_media_type_string
Simples/ffmpeg-3.3.3/libavcodec/utils.c:3260: undefined reference to `av_fourcc_make_string'
Simples/app/src/main/cpp/../../../../ffmpeg-3.3.3/build/android/arm64-v8a/lib/libavformat.a(apngenc.o): In function `apng_write_chunk':
Simples/ffmpeg-3.3.3/libavformat/apngenc.c:64: undefined reference to `av_crc_get_table'
Simples/ffmpeg-3.3.3/libavformat/apngenc.c:72: undefined reference to `av_crc'
Simples/ffmpeg-3.3.3/libavformat/apngenc.c:75: undefined reference to `av_crc'
Simples/app/src/main/cpp/../../../../ffmpeg-3.3.3/build/android/arm64-v8a/lib/libavformat.a(apngenc.o): In function `flush_packet':
Simples/ffmpeg-3.3.3/libavformat/apngenc.c:209: undefined reference to `av_crc_get_table'
Simples/ffmpeg-3.3.3/libavformat/apngenc.c:209: undefined reference to `av_crc'

出现该问题很可能是target_link_librarie()中依赖库的顺序不对,需要调整target_link_librarie() 中依赖库的顺序。
比如这里 `av_get_media_type_string’ avutil中一个函数,所以,可以看出   libavcodec 是 依赖 lib avutil的 ,则 avcodec 必须写在avutil 的前面。
切记:是  avcodec  写在 avutil  的前面,而不是后面。
target_link_libraries( # Specifies the target library.
                       ffmpeg-lib

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib}
                       ${android-lib}
                       swscale
                       avformat
                       avcodec
                       swresample
                       avutil
                       avfilter
                       ${z-lib}
                       ${m-lib}
                       ) 

你可能感兴趣的:(Android)