How can I solve this error while making OpenCV?
I am trying to compile OpenCV but I get this error almost at the end of running make.
[ 93%] Built target pch_Generate_opencv_videostab
[ 96%] Built target opencv_videostab
Linking CXX shared library ../../lib/cv2.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/cv2.so] 오류 1
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] 오류 2
make: *** [all] 오류 2
OS: CentOS 6.6
You should add -fPIC to your compiler options before running CMAKE! Then it will run just fine. How to do so can be found here.
Pardon my ignorance but regarding to OpenCV case, which file exactly should I add this flag? I created a release directory and runed cmake from there. You told me to add the -fPIC before cmake, but to which file?
Maybe the problem is in your libpython2.7.a, not in OpenCV? On my machine dynamic libpython*.so is used, for example. You can try to disable python wrappers if you do not need them:
It does work if I remove it but I do need python wrappers. What can I do?
Try to reinstall python development package, or install separate python development library (maybe even build it yourself). Pass paths to python library and headers to cmake when building OpenCV (example here: http://pullrequest.opencv.org/buildbo...). Always build in clean directory.