我尝试使用此处的说明安装 opencv,但每次都会出现错误
Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32 against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:191: recipe for target 'lib/libopencv_videoio.so.3.0.0' failed
make[2]: *** [lib/libopencv_videoio.so.3.0.0] Error 1
CMakeFiles/Makefile2:4022: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:133: recipe for target 'all' failed
make: *** [all] Error 2
当我运行cmake -D CMAKE_BUILD_TYPE=RELEASE ..
时,它说一切都很好并且库已安装。可能会发生什么,我该如何解决?
参考这个 StackOverflow 问题:Installing OpenCV in Ubuntu 14.10
您可以根据 OpenCV 的需要
cmake
使用-D WITH_FFMPEG=OFF
或手动编译版本 9 的 FFmpeg。