python连接opencv库_OpenCV的Python的连接错误

1586010002-jmsa.png

I've been trying to install opencv on heroku to no avail. I've tried using heroku-anvil for the installation and am now trying to install opencv via the bash shell. First I installed cmake but then when I try to make opencv I inevitably get the following error:

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] Error 1

make[1]: *** [modules/python/CMakeFiles/opencv_python.dir/all] Error 2

make: *** [all] Error 2

Here are the exact commands that I'm using:

# connect to bash shell

heroku run bash

cd /tmp

# Downloading and Installing cmake:

curl -s http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.Z > cmake.tar.gz

tar zxf cmake.tar.gz

cd cmake-2.8.12.1/

./bootstrap

make

make install

# Download and Install OpenCV

curl -s https://s3.amazonaws.com/nerdglasses/opencv/OpenCV-2.4.2.tar.bz2 > opencv.tar.gz

tar xf opencv.tar.gz

cd OpenCV-2.4.2/

../cmake-2.8.12.1/bin/cmake -DBUILD_SHARED_LIBS=NO -DCMAKE_SHARED_LINKER_FLAGS="-fPIC" -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DWITH_OPENEXR=OFF -DCMAKE_FIND_ROOT_PATH=/app/.heroku -DCMAKE_INSTALL_PREFIX=/app/.heroku .

make # ERROR HERE

Anyone know how to fix this? Or if there is a better way to get opencv installed on heroku for a python web app?

解决方案

You need to reinstall python with shared and static way.

Firstly, download Python source file again.

and then..

./configure --enable-shared --enable-static

make

make install

In that way you might solve this problem out.

Here's the link that you might want to know.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值