[英]Compiling opencv with python support error
I am trying to install opencv with python support and I am facing with an issue which I cant help on. 我正在尝试使用python支持安装opencv,我正面临一个我无法帮助的问题。
When I configure the project with cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
it configures and says python support present. 当我使用cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
配置项目cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
它配置并说python支持存在。
-- Python:
-- Interpreter: /usr/local/bin/python2 (ver 2.7.10)
-- Libraries: /usr/local/lib/libpython2.7.a (ver 2.7.10)
-- numpy: /usr/local/lib/python2.7/site-packages/numpy/core/include (ver 1.9.2)
-- packages path: lib/python2.7/site-packages
When I try to make
it, it fails at 当我尝试make
时,它失败了
[ 75%] Built target opencv_test_contrib
Linking CXX shared library ../../lib/cv2.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol' 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] Error 1
make[1]: *** [modules/python/CMakeFiles/opencv_python.dir/all] Error 2
make: *** [all] Error 2
It builds just fine without python support. 它没有python支持就构建得很好。
I did not understand what this error means / how to fix this as I dont have much experience with cmake. 我不明白这个错误意味着什么/如何解决这个问题,因为我对cmake没有多少经验。 Any help to debug this is appreciated. 任何有关调试的帮助表示赞赏。
As the error says, you need to recompile with the "-fPIC" flag. 如错误所示,您需要使用“-fPIC”标志重新编译。 Some research pulls up the easy fix. 一些研究提出了简单的解决方案。 Add to the command -D CMAKE_C_FLAGS=-fPIC
, so that your whole command is cmake -D CMAKE_C_FLAGS=-fPIC -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
添加到命令-D CMAKE_C_FLAGS=-fPIC
,以便整个命令是cmake -D CMAKE_C_FLAGS=-fPIC -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
Please let the rest of the internet know if this works or not. 如果这有效,请让其他人知道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.