Linux下OpenCV2.4.13.6编译时报错:
/usr/bin/ld: /usr/local/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:638: recipe for target 'lib/libopencv_highgui.so.2.4.13' failed
make[2]: *** [lib/libopencv_highgui.so.2.4.13] Error 1
CMakeFiles/Makefile2:1934: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
解决方案:
1.重新编译ffmpeg,加参数:--enable-shared
./configure --enable-shared
make
sudo make install
2.opencv重新编辑cmake
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install