【问题标题】:Errors while building customised ffmpeg4.1 with opencv使用 opencv 构建自定义 ffmpeg4.1 时出错
【发布时间】:2020-04-07 00:20:58
【问题描述】:

我正在尝试构建我的自定义 ffmpeg 版本 4.1。我们知道 ffmpeg4.1 需要 libavcodec.so.58 和其他相关库(最新)。我的代码中有一些与 opencv 相关的函数,例如 cvLoadImage 等。我更新了 libopencv-highgui-dev、libopencv_core-dev 和 libopencv_imgproc-dev 库。当我运行 makefile 时,出现以下错误,

/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_free_packet@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_write_frame@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_frame_alloc@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_free_context@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_write_header@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_rescale_q@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_write_trailer@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `sws_getCachedContext@LIBSWSCALE_4'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avcodec_find_encoder@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_free@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avcodec_encode_video2@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_seek_frame@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_lockmgr_register@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avcodec_decode_video2@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avcodec_open2@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_malloc@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avio_close@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_init_packet@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_log_set_level@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avpicture_get_size@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_get_riff_video_tags@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_close_input@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avpicture_fill@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_network_init@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_find_stream_info@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avcodec_close@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_guess_codec@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avio_open@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_guess_format@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_open_input@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_register_all@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `sws_getContext@LIBSWSCALE_4'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_new_stream@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_frame_free@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_sub_q@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_freep@LIBAVUTIL_55'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avcodec_find_decoder@LIBAVCODEC_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `sws_freeContext@LIBSWSCALE_4'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `sws_scale@LIBSWSCALE_4'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avformat_alloc_context@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_read_frame@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `av_codec_get_id@LIBAVFORMAT_57'
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to `avcodec_flush_buffers@LIBAVCODEC_57'
collect2: error: ld returned 1 exit status
make: *** [new-ffmpeg] Error 1

我已经清楚地链接了最新的库并将它们包含在我的 makefile 中。错误列表提示我,libopencv-highgui.so 指向 libavcodec.57 版本的 api。 opencv 是否没有升级为支持 libavXX.so.58 库?还是我在这里做错了什么。

请帮助我,否则任何建议都会有所帮助。

【问题讨论】:

  • 它显然在提供的日志中寻找 libavcodec_57。不知道你究竟是如何构建 OpenCV 的,很难说。并且提供的错误不是关于“API”,而是它试图链接的库和引用。
  • @Kamiccolo 感谢您的回复,那么构建我的自定义 ffmpeg 的解决方案是什么?我们不能做点什么吗?我们可以将这个 libopencv_highgui 库链接到 libav 吗?还是我需要使用 libav 较新的库编译和构建 libopencv_highgui 的二进制文件?有可能吗?
  • 您使用的是什么操作系统/版本?
  • @Manthan Tilva 我正在使用 Debian Stretch,64 位。
  • 你使用的是什么版本的 OpenCV?

标签: c opencv ffmpeg libav


【解决方案1】:

可能是你的opencv安装有问题请参考这个问题Here

【讨论】:

  • 我按照您建议的流程进行操作,但出现此错误,/usr/bin/ld: warning: libavcodec.so.57, needed by /usr/lib/x86_64-linux-gnu/libopencv_highgui .so,可能与 libavcodec.so.58 /usr/bin/ld 冲突:警告:libavformat.so.57,/usr/lib/x86_64-linux-gnu/libopencv_highgui.so 需要,可能与 libavformat.so 冲突。 58 /usr/bin/ld:警告:libavutil.so.55,/usr/lib/x86_64-linux-gnu/libopencv_highgui.so需要,可能与libavutil.so.56冲突/usr/bin/ld:警告: /usr/lib/x86_64-linux-gnu/libopencv_highgui.so 需要的 libswscale.so.4 可能与 libswscale.so.5 冲突
猜你喜欢
  • 2018-04-03
  • 1970-01-01
  • 2021-09-30
  • 1970-01-01
  • 2017-07-20
  • 1970-01-01
  • 1970-01-01
  • 2021-04-14
相关资源
最近更新 更多