1

i use this cmake for installation opencv

cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=OFF \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ -D BUILD_EXAMPLES=ON ..

Everything seems right

enter image description here

 Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
-- 
--   Python 3:
--     Interpreter:                 /usr/local/bin/python3 (ver 3.5.2)
--     Libraries:                   /usr/local/lib/libpython3.5m.a (ver 3.5.2)
--     numpy:                       /home/rezaoptic/.local/lib/python3.5/site-packages/numpy/core/include (ver 1.11.2)
--     packages path:               lib/python3.5/site-packages

but when i use make -j4 in 100% i take this error enter image description here

 [100%] Linking CXX shared module ../../lib/python3/cv2.cpython-35m-x86_64-linux-gnu.so
/usr/bin/ld: /usr/local/lib/libpython3.5m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython3.5m.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
modules/python3/CMakeFiles/opencv_python3.dir/build.make:224: recipe for target 'lib/python3/cv2.cpython-35m-x86_64-linux-gnu.so' failed
make[2]: *** [lib/python3/cv2.cpython-35m-x86_64-linux-gnu.so] Error 1
CMakeFiles/Makefile2:6985: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

what is wrong ? and how can i fix it ?

Edit Solve:

if someone have this problem careful about :

--     Libraries:                   /usr/local/lib/libpython3.5m.a (ver 3.5.2)

i change my cmake to :

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D PYTHON3_EXECUTABLE=/usr/bin/python3.5 -D PYTHON_INCLUDE_DIR=/usr/include/python3.5 -D PYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python3.5 -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include/ ..

and Then i have :

--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.5m.so (ver 3.5.2)

sorry for my English if someone have time edit my post for better English :)

RezaOptic
  • 310
  • 1
  • 4
  • 16
  • *Relocation R_X86_64_32S against `_Py_NotImplementedStruct` can not be used when making a shared object;* ***recompile with -fPIC*** – Frédéric Hamidi Nov 01 '16 at 08:07
  • and ..... how ? – RezaOptic Nov 01 '16 at 08:21
  • You apparently have to rebuild Python with the `-fPIC` flag. This can be done through your package manager, but your Python residing in `/usr/local` makes me think it's a custom build, so you might be on your own. Check the `configure` script you're running. – Frédéric Hamidi Nov 01 '16 at 08:27

0 Answers0