我已经在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...