2013-10-17 119 views
6

我正嘗試使用自制軟件將我的OpenCV從版本2.4.5更新到版本2.4.6.1。當我運行 brew upgrade opencv
我遇到了以下錯誤:在Mac OS X 10.9中使用自制軟件構建OpenCV_Python

==> Upgrading opencv 
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid 
==> Downloading http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.6.1/opencv-2.4 
Already downloaded: /Library/Caches/Homebrew/opencv-2.4.6.1.tar.gz 
==> cmake -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/2.4.6.1 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIN 
==> make 
/usr/local/Library/ENV/4.3/c++ -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -dynamiclib -Wl,-headerpad_max_install_names -o ../../lib/libopencv_java246.dylib -install_name /tmp/-5W3i/opencv-2.4.6.1/macbuild/lib/libopencv_java246.dylib CMakeFiles/opencv_java.dir/generator/src/cpp/converters.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/core_manual.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/jni_part.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/Mat.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/utils.cpp.o CMakeFiles/opencv_java.dir/generator/src/cpp/VideoCapture.cpp.o CMakeFiles/opencv_java.dir/core.cpp.o CMakeFiles/opencv_java.dir/imgproc.cpp.o CMakeFiles/opencv_java.dir/objdetect.cpp.o CMakeFiles/opencv_java.dir/features2d.cpp.o CMakeFiles/opencv_java.dir/video.cpp.o CMakeFiles/opencv_java.dir/highgui.cpp.o CMakeFiles/opencv_java.dir/ml.cpp.o CMakeFiles/opencv_java.dir/calib3d.cpp.o CMakeFiles/opencv_java.dir/photo.cpp.o CMakeFiles/opencv_java.dir/contrib.cpp.o -L/usr/local/include/../lib ../../lib/libopencv_core.2.4.6.dylib ../../lib/libopencv_imgproc.2.4.6.dylib ../../lib/libopencv_highgui.2.4.6.dylib ../../lib/libopencv_objdetect.2.4.6.dylib ../../lib/libopencv_flann.2.4.6.dylib ../../lib/libopencv_features2d.2.4.6.dylib ../../lib/libopencv_video.2.4.6.dylib ../../lib/libopencv_ml.2.4.6.dylib ../../lib/libopencv_calib3d.2.4.6.dylib ../../lib/libopencv_photo.2.4.6.dylib ../../lib/libopencv_legacy.2.4.6.dylib ../../lib/libopencv_gpu.2.4.6.dylib ../../lib/libopencv_ocl.2.4.6.dylib ../../lib/libopencv_nonfree.2.4.6.dylib ../../lib/libopencv_contrib.2.4.6.dylib -ltbb ../../lib/libopencv_gpu.2.4.6.dylib ../../lib/libopencv_photo.2.4.6.dylib ../../lib/libopencv_legacy.2.4.6.dylib ../../lib/libopencv_ocl.2.4.6.dylib ../../lib/libopencv_objdetect.2.4.6.dylib ../../lib/libopencv_video.2.4.6.dylib ../../lib/libopencv_ml.2.4.6.dylib ../../lib/libopencv_calib3d.2.4.6.dylib ../../lib/libopencv_features2d.2.4.6.dylib ../../lib/libopencv_highgui.2.4.6.dylib ../../lib/libopencv_imgproc.2.4.6.dylib ../../lib/libopencv_flann.2.4.6.dylib ../../lib/libopencv_core.2.4.6.dylib /usr/lib/libz.dylib -ltbb -framework OpenCL 
brew: superenv removed: -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -L/usr/local/include/../lib 
usr/local/Cellar/cmake/2.8.11.2/bin/cmake -E cmake_progress_report /tmp/-5W3i/opencv-2.4.6.1/macbuild/CMakeFiles 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 
[100%] Built target opencv_java 
make: *** [all] Error 2 

似乎同時建設的OpenCV的Python綁定來失敗。我在我的Mac上安裝了Java版本1.7.0_45-b18,並且在Numpy 1.7.1上安裝了Python 2.7.5。我想知道這裏會有什麼問題。

進一步調試揭示了問題,同時建立OpenCV_Python引起的,這正是構建停止錯誤:

[ 85%] Building CXX object modules/python/CMakeFiles/opencv_python.dir/src2/cv2.cpp.o 
cd /tmp/opencv-fc49/opencv-2.4.6.1/macbuild/modules/python && /usr/local/Library/ENV/4.3/c++ -DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_CVCONFIG_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H -DPYTHON_USE_NUMPY=1 -Dopencv_python_EXPORTS -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -fdiagnostics-show-option -fno-omit-frame-pointer -msse -msse2 -msse3 -Wno-unused-function -fPIC -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2 -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/nonfree/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/ocl/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/gpu/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/legacy/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/contrib/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/objdetect/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/photo/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/calib3d/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/features2d/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/highgui/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/ml/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/video/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/imgproc/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/flann/include -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/core/include -I/tmp/opencv-fc49/opencv-2.4.6.1/macbuild/modules/python -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src -I/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/include -I/tmp/opencv-fc49/opencv-2.4.6.1/macbuild -isystem /usr/local/include -isystem /usr/local/include/eigen3 -isystem /usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/Headers -isystem /usr/local/lib/python2.7/site-packages/numpy/core/include -o CMakeFiles/opencv_python.dir/src2/cv2.cpp.o -c /tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp 
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:227:9: error: no matching function for call to 'PyInt_Check' 
if(PyInt_Check(o)) 
    ^~~~~~~~~~~ 
/usr/local/include/pypy_decl.h:171:17: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier 
PyAPI_FUNC(int) PyInt_Check(PyObject *arg0); 
       ^
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:233:9: error: no matching function for call to 'PyFloat_Check' 
if(PyFloat_Check(o)) 
    ^~~~~~~~~~~~~ 
/usr/local/include/pypy_decl.h:142:17: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier 
PyAPI_FUNC(int) PyFloat_Check(PyObject *arg0); 
       ^
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:239:9: error: no matching function for call to 'PyTuple_Check' 
if(PyTuple_Check(o)) 
    ^~~~~~~~~~~~~ 
/usr/local/include/pypy_decl.h:397:17: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier 
PyAPI_FUNC(int) PyTuple_Check(PyObject *arg0); 
       ^
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:245:28: error: no matching function for call to 'PyTuple_GetItem' 
     PyObject* oi = PyTuple_GET_ITEM(o, i); 
         ^~~~~~~~~~~~~~~~ 
/usr/local/include/tupleobject.h:14:26: note: expanded from macro 'PyTuple_GET_ITEM' 
#define PyTuple_GET_ITEM PyTuple_GetItem 
         ^~~~~~~~~~~~~~~ 
/usr/local/include/pypy_decl.h:400:24: note: candidate function not viable: 1st argument ('const PyObject *' (aka 'const _object *')) would lose const qualifier 
PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *arg0, Py_ssize_t arg1); 
        ^
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:702:28: error: use of undeclared identifier 'PySequence_Fast_ITEMS'; did you mean 'PySequence_Fast_GET_SIZE'? 
    PyObject** items = PySequence_Fast_ITEMS(seq); 
         ^~~~~~~~~~~~~~~~~~~~~ 
         PySequence_Fast_GET_SIZE 
/usr/local/include/pypy_decl.h:339:24: note: 'PySequence_Fast_GET_SIZE' declared here 
PyAPI_FUNC(Py_ssize_t) PySequence_Fast_GET_SIZE(PyObject *arg0); 
        ^
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:702:20: error: cannot initialize a variable of type 'PyObject **' (aka '_object **') with an rvalue of type 'Py_ssize_t' (aka 'long') 
    PyObject** items = PySequence_Fast_ITEMS(seq); 
      ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~ 
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:741:27: error: use of undeclared identifier 'PySequence_Fast_ITEMS'; did you mean 'PySequence_Fast_GET_SIZE'? 
      items_i = PySequence_Fast_ITEMS(seq_i); 
         ^~~~~~~~~~~~~~~~~~~~~ 
         PySequence_Fast_GET_SIZE 
/usr/local/include/pypy_decl.h:339:24: note: 'PySequence_Fast_GET_SIZE' declared here 
PyAPI_FUNC(Py_ssize_t) PySequence_Fast_GET_SIZE(PyObject *arg0); 
       ^
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:741:25: error: assigning to 'PyObject **' (aka '_object **') from incompatible type 'Py_ssize_t' (aka 'long') 
      items_i = PySequence_Fast_ITEMS(seq_i); 
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:814:24: error: use of undeclared identifier 'PySequence_Fast_ITEMS'; did you mean 'PySequence_Fast_GET_SIZE'? 
PyObject** items = PySequence_Fast_ITEMS(seq); 
        ^~~~~~~~~~~~~~~~~~~~~ 
        PySequence_Fast_GET_SIZE 
/usr/local/include/pypy_decl.h:339:24: note: 'PySequence_Fast_GET_SIZE' declared here 
PyAPI_FUNC(Py_ssize_t) PySequence_Fast_GET_SIZE(PyObject *arg0); 
        ^
/tmp/opencv-fc49/opencv-2.4.6.1/modules/python/src2/cv2.cpp:814:16: error: cannot initialize a variable of type 'PyObject **' (aka '_object **') with an rvalue of type 'Py_ssize_t' (aka 'long') 
PyObject** items = PySequence_Fast_ITEMS(seq); 

任何人都可以請建築OpenCV的幫助?

+1

你可以參考我的答案在這裏: http://stackoverflow.com/questions/19707468/installing-opencv-2-4-2-on-mac-os-x-10-9-mavericks/19929313#19929313 HTH – GilbertLee

+0

嘗試從源代碼安裝numpy,scipy和opencv。在編譯這些庫之前,需要設置以下環境變量:「export ARCHFLAGS = -Wno-error = unused-command-line-argument-hard-error-in-future」 –

回答

0

你可能會得到圍繞Py *函數的編譯器錯誤,因爲它無法在其搜索目錄中找到python包含的東西。

我不會依賴股票python構建,並建議通過python安裝另一個版本。這兩個python版本可以共存於同一臺機器上,但最好依靠brew的安裝。您可以通過檢查「哪個python」指向/ usr/local/bin/python或從啓動python解釋器時的版本來驗證它。 GilberLee的評論指出了一些很好的步驟來設置:Installing openCV 2.4.2 on Mac OS X 10.9 (Mavericks)

安裝python視圖homebrew後,嘗試重新安裝opencv,看看你是否通過這些編譯錯誤。