在构建文件夹外运行OpenCV时找不到符号

时间:2016-03-19 00:36:19

标签: python macos opencv dll makefile

我已经在OSX上安装了OpenCV,如下所示:

(cv1) $ cd ~/opencv
(cv1) $ mkdir build
(cv1) $ cd build
(cv1) $ cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local/include \
    -D PYTHON3_PACKAGES_PATH=~/.virtualenvs/cv1/lib/python3.5/site-packages \
    -D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib \
    -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/include/python3.5m \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON \
    -D BUILD_opencv_python3=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/code/opencv_contrib/modules ..
(cv1) $ make -j4 && sudo make install

当我从build内部执行程序时,它们运行正常,但是,当我离开build文件夹时,我收到Symbol not found错误:

(cv1)➜  opencv git:(master) ✗ python ~/code/myprogram.py ~/myimg.jpg
Traceback (most recent call last):
  File "/Users/omni/code/myprogram.py", line 6, in <module>
    import cv2
ImportError: dlopen(/Users/omni/.virtualenvs/cv1/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so, 2): Symbol not found: __ZN2cv4text10erGroupingERKNS_11_InputArrayES3_NSt3__16vectorINS5_INS_6Point_IiEENS4_9allocatorIS7_EEEENS8_ISA_EEEERNS5_INS_5Rect_IiEENS8_ISE_EEEEiRKNS_6StringEf
  Referenced from: /Users/omni/.virtualenvs/cv1/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so
  Expected in: /usr/local/lib/libopencv_text.3.0.dylib
 in /Users/omni/.virtualenvs/cv1/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so
(cv1)➜  opencv git:(master) ✗ cd build
(cv1)➜  build git:(master) ✗ python ~/code/myprogram.py ~/myimg.jpg
      ...running program...

0 个答案:

没有答案