Ask Your Question
1

How can I solve this error while making OpenCV?

asked 2015-07-29 02:34:43 -0600

cacyss0807 gravatar image

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

edit retag flag offensive close merge delete

Comments

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.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-29 02:48:07 -0600 )edit
1

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?

cacyss0807 gravatar imagecacyss0807 ( 2015-07-29 03:12:42 -0600 )edit
1

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:

cmake -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF ...
mshabunin gravatar imagemshabunin ( 2015-07-29 04:10:39 -0600 )edit
2

It does work if I remove it but I do need python wrappers. What can I do?

cacyss0807 gravatar imagecacyss0807 ( 2015-08-03 03:35:50 -0600 )edit

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.

mshabunin gravatar imagemshabunin ( 2015-08-06 04:14:01 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2016-02-11 15:55:15 -0600

ccaseyldc gravatar image

Please let me know if you found an answer to this. I'm having exactly the same issue.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-07-29 02:33:59 -0600

Seen: 1,085 times

Last updated: Jul 29 '15