Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

“Undefined reference to `avcodec_alloc_frame” Error when compile and install Opencv on linux

I am compiling and installing OpenCV using the steps in http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html

But during "making" it, it has error when it reaches 45%. The error message is

...
[ 43%] Built target pch_Generate_opencv_video
[ 44%] Built target opencv_video
[ 44%] Built target opencv_p erf_video_pch_dephelp
[ 45%] Built target pch_Generate_opencv_perf_video  
Linking CXX executable ../../bin/opencv_perf_video
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avcodec_alloc_frame'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avcodec_encode_video'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/opencv_perf_video] Error 1
make[1]: *** [modules/video/CMakeFiles/opencv_perf_video.dir/all] Error 2
make: *** [all] Error 2

I downloaded and installed the latest version of ffmpeg from https://www.ffmpeg.org/.

Anyone knows how can I fix the errors?

Thank you.

“Undefined reference to `avcodec_alloc_frame” Error when compile and install Opencv on linux

I am compiling and installing OpenCV using the steps in http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html

But during "making" it, it has error when it reaches 45%. The error message is

...
[ 43%] Built target pch_Generate_opencv_video
[ 44%] Built target opencv_video
[ 44%] Built target opencv_p erf_video_pch_dephelp
[ 45%] Built target pch_Generate_opencv_perf_video  
Linking CXX executable ../../bin/opencv_perf_video
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avcodec_alloc_frame'
../../lib/libopencv_videoio.so.3.1.0: undefined reference to `avcodec_encode_video'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/opencv_perf_video] Error 1
make[1]: *** [modules/video/CMakeFiles/opencv_perf_video.dir/all] Error 2
make: *** [all] Error 2

I downloaded and installed the latest version of ffmpeg from https://www.ffmpeg.org/.https://www.ffmpeg.org/. And I installed ffmpeg following the steps on the compilation guide page https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu. I followed the steps and installed all the dependencies and libraries mentioned in the guide.

Anyone knows how can I fix the errors?

Thank you.