/usr/bin/ld:/usr/local/lib/libavutil.a(log.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/libavutil.a: error addingsymbols: Bad value
However, during the compilation process I get the following error.
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
make[2]:***[lib/libopencv_videoio.so.3.0.0]Error1
make[1]:***[modules/videoio/CMakeFiles/opencv_videoio.dir/all]Error2
make:***[all]Error2
I noticed a few posts mentioning similar errors and some solutions suggest removing the libavcodec.a from /usr/local/lib/. I'd like not to do that as I need ffmpeg libraries in the machine as well.
Could someone please help me to resolve this issue?.
Yes. I tried editing the cmake list file by adding set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" ). But that didn't work. I also tried to recompile ffmpeg with --enable-shared. But that didn't work as well. –
userDtrmMar 10 '15 at 11:48
Did you try to remove the libavcodec.a from the folder /usr/local/lib then rerun the compilation? You can move libavcodec.a to somewhere else then put it back to /usr/local/lib once you've done with opencv compilation. –
Ha DangMar 10 '15 at 12:08
I had to remove libavformat.a libavutil.a libavcodec.a libswscale.a from /usr/local/lib and then compile opencv. Then the removed files were copied back to the location. It seems to have worked. Thanks a lot for the help. –
userDtrmMar 10 '15 at 18:14