我似乎无法使用ffmpeg 2.7或2.4正确构建OpenCV 3.0。有谁知道哪个版本有效?我正在运行Mac OSX Yosemite。在尝试使用ffmpeg支持构建opencv时,我似乎遇到了链接错误:
Linking CXX shared library ../../lib/libopencv_videoio.dylib
Undefined symbols for architecture x86_64:
"_iconv", referenced from:
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
"_iconv_close", referenced from:
_avcodec_open2 in libavcodec.a(utils.o)
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
"_iconv_open", referenced from:
_avcodec_open2 in libavcodec.a(utils.o)
_avcodec_decode_subtitle2 in libavcodec.a(utils.o)
"_lzma_code", referenced from:
_decode_frame in libavcodec.a(tiff.o)
"_lzma_end", referenced from:
_decode_frame in libavcodec.a(tiff.o)
"_lzma_stream_decoder", referenced from:
_decode_frame in libavcodec.a(tiff.o)
"_swr_alloc", referenced from:
_opus_decode_init in libavcodec.a(opusdec.o)
"_swr_close", referenced from:
_opus_decode_packet in libavcodec.a(opusdec.o)
_opus_decode_flush in libavcodec.a(opusdec.o)
"_swr_convert", referenced from:
_opus_decode_packet in libavcodec.a(opusdec.o)
"_swr_free", referenced from:
_opus_decode_close in libavcodec.a(opusdec.o)
"_swr_init", referenced from:
_opus_decode_packet in libavcodec.a(opusdec.o)
"_swr_is_initialized", referenced from:
_opus_decode_packet in libavcodec.a(opusdec.o)
"_x264_bit_depth", referenced from:
_X264_init_static in libavcodec.a(libx264.o)
_X264_frame in libavcodec.a(libx264.o)
"_x264_encoder_close", referenced from:
_X264_close in libavcodec.a(libx264.o)
"_x264_encoder_delayed_frames", referenced from:
_X264_frame in libavcodec.a(libx264.o)
"_x264_encoder_encode", referenced from:
_X264_frame in libavcodec.a(libx264.o)
"_x264_encoder_headers", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_encoder_open_142", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_encoder_reconfig", referenced from:
_X264_frame in libavcodec.a(libx264.o)
"_x264_levels", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_param_apply_fastfirstpass", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_param_apply_profile", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_param_default", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_param_default_preset", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_param_parse", referenced from:
_X264_init in libavcodec.a(libx264.o)
"_x264_picture_init", referenced from:
_X264_frame in libavcodec.a(libx264.o)
"_xvid_encore", referenced from:
_xvid_encode_init in libavcodec.a(libxvid.o)
_xvid_encode_frame in libavcodec.a(libxvid.o)
_xvid_encode_close in libavcodec.a(libxvid.o)
"_xvid_global", referenced from:
_xvid_encode_init in libavcodec.a(libxvid.o)
"_xvid_plugin_2pass2", referenced from:
_xvid_encode_init in libavcodec.a(libxvid.o)
_ff_xvid_rate_control_init in libavcodec.a(libxvid_rc.o)
_ff_xvid_rate_estimate_qscale in libavcodec.a(libxvid_rc.o)
_ff_xvid_rate_control_uninit in libavcodec.a(libxvid_rc.o)
"_xvid_plugin_lumimasking", referenced from:
_xvid_encode_init in libavcodec.a(libxvid.o)
"_xvid_plugin_single", referenced from:
_xvid_encode_init in libavcodec.a(libxvid.o)
"_xvid_plugin_ssim", referenced from:
_xvid_encode_init in libavcodec.a(libxvid.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_videoio.3.0.0.dylib] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
以下是我编译ffmpeg的标志,也许这可能是原因?:
./ configure --prefix =〜/ Software / ffmpeg-2.4.10 / --enable-shared --enable-avresample --enable-libx264 --enable-libxvid --enable-opencl --enable-gpl
答案 0 :(得分:1)
其中大多数都不是ffmpeg(libavcodec,libavformat,libavutils,libswscale等)链接器错误。它们是依赖关系ffmpeg是用:iconv,swresample(它是ffmpeg的一部分),lzma,x264和xvid构建的。您需要链接到libiconv,libswresample,liblzma,libx264和libxvid。
特定版本的ffmpeg不是问题所在。问题是ffmpeg有一些你需要链接的依赖项。
如果需要,您可以--enable-libx264
,但您需要在您的计算机上实际拥有libx264,以便OpenCV / ffmpeg能够链接到。与所有其他人一样。