在OS X上从源代码编译最新的OpenCV(使用Cmake)



我的问题:

我在Mac OS X上使用cmake从SVN编译最新的OpenCV,它在终端输出结束时出现错误。我对Cmake不够熟悉,无法真正找到问题所在。这是什么意思?

下面是最后几行输出:
CMake Error at modules/highgui/cmake_install.cmake:38 (FILE):
  file INSTALL cannot find "/Users/Matt/OpenCV/build/tmp/lib/Release/libopencv_highgui.a".
Call Stack (most recent call first):
  modules/cmake_install.cmake:36 (INCLUDE)
  cmake_install.cmake:45 (INCLUDE)

make: *** [install_buildpart_0] Error 1
Command /bin/sh failed with exit code 2
Command /bin/sh failed with exit code 2
** BUILD FAILED **

The following build commands failed:
opencv_highgui:
    CompileC "/Users/Matt/OpenCV/build/tmp/modules/highgui/
        OpenCV.build/Release-iphonesimulator/opencv_highgui.build/
        Objects-normal/i386/cap_avfoundation.o" 
        "/Users/Matt/OpenCV/opencv/modules/highgui/src/cap_avfoundation.mm" 
        normal i386 objective-c++ com.apple.compilers.gcc.4_2
install:
    PhaseScriptExecution "CMake PostBuild Rules" "/Users/Matt/OpenCV/build/tmp/
        OpenCV.build/Release-iphonesimulator/install.build/
        Script-10907B010907B010907B0000.sh"

我是如何到达这里的:

我从github下载了Aptogo OpenCV框架https://github.com/aptogo/OpenCVForiPhone

这是一个bash脚本编译OpenCV与Cmake,并把结果变成一个XCode框架(我认为):

https://github.com/aptogo/OpenCVForiPhone/blob/master/opencvbuild.sh

我从SVN上找到了最新的OpenCV源代码,并在上面运行了这个脚本。

更多错误

找到对cap_avfoundation的引用。嗯,在日志的前面。

CompileC "/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/Objects-normal/i386/cap_avfoundation.o" modules/highgui/src/cap_avfoundation.mm normal i386 objective-c++ com.apple.compilers.gcc.4_2
    cd "/Users/Matt/OpenCV/opencv"
    setenv LANG en_US.US-ASCII
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/mattmontag/Unix/pvc/UTILITIES:/Users/mattmontag/Unix/pvc/bin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O3 -DCMAKE_INTDIR="Release" -DHAVE_ALLOCA -DHAVE_ALLOCA_H -DHAVE_LIBPTHREAD -DHAVE_UNISTD_H -DHAVE_CVCONFIG_H -DHAVE_IMAGEIO=1 -DHAVE_COCOA=1 -DHAVE_AVFOUNDATION=1 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fexceptions -mmacosx-version-min=10.6 -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40200 -Wmost -Wno-four-char-constants -Wno-unknown-pragmas "-F/Users/Matt/OpenCV/build/tmp/lib/Release" "-I/Users/Matt/OpenCV/build/tmp/lib/Release/include" "-I/Users/Matt/OpenCV/opencv" "-I/Users/Matt/OpenCV/build/tmp" "-I/Users/Matt/OpenCV/opencv/include" "-I/Users/Matt/OpenCV/opencv/include/opencv" "-I/Users/Matt/OpenCV/opencv/modules/highgui/include" "-I/Users/Matt/OpenCV/opencv/modules/highgui/../core/include" "-I/Users/Matt/OpenCV/opencv/modules/highgui/../imgproc/include" "-I/Users/Matt/OpenCV/opencv/modules/highgui/src" "-I/Users/Matt/OpenCV/build/tmp/modules/highgui" "-I/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/DerivedSources/i386" "-I/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/DerivedSources" -c "cap_avfoundation.mm" -o "/Users/Matt/OpenCV/build/tmp/modules/highgui/OpenCV.build/Release-iphonesimulator/opencv_highgui.build/Objects-normal/i386/cap_avfoundation.o"
cap_avfoundation.mm:59: error: cannot find protocol declaration for 'AVCaptureVideoDataOutputSampleBufferDelegate'
cap_avfoundation.mm:71: error: expected type-specifier before 'AVCaptureOutput'
cap_avfoundation.mm:71: error: expected `)' before 'AVCaptureOutput'
cap_avfoundation.mm:71: error: expected `;' before '*' token
cap_avfoundation.mm:101: error: ISO C++ forbids declaration of 'AVCaptureSession' with no type
cap_avfoundation.mm:101: error: expected ';' before '*' token
cap_avfoundation.mm:102: error: ISO C++ forbids declaration of 'AVCaptureDeviceInput' with no type
cap_avfoundation.mm:102: error: expected ';' before '*' token
cap_avfoundation.mm:103: error: ISO C++ forbids declaration of 'AVCaptureVideoDataOutput' with no type
cap_avfoundation.mm:103: error: expected ';' before '*' token
cap_avfoundation.mm:104: error: ISO C++ forbids declaration of 'AVCaptureDevice' with no type
cap_avfoundation.mm:104: error: expected ';' before '*' token
cap_avfoundation.mm: In constructor 'CvCaptureCAM::CvCaptureCAM(int)':
cap_avfoundation.mm:236: error: 'mCaptureSession' was not declared in this scope
cap_avfoundation.mm:237: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:238: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm: In member function 'void CvCaptureCAM::stopCaptureDevice()':
cap_avfoundation.mm:308: error: 'mCaptureSession' was not declared in this scope
cap_avfoundation.mm:311: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:313: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm: In member function 'int CvCaptureCAM::startCaptureDevice(int)':
cap_avfoundation.mm:324: error: 'AVCaptureDevice' was not declared in this scope
cap_avfoundation.mm:324: error: 'device' was not declared in this scope
cap_avfoundation.mm:341: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:347: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:347: error: 'AVCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:348: error: 'mCaptureSession' was not declared in this scope
cap_avfoundation.mm:348: error: 'AVCaptureSession' was not declared in this scope
cap_avfoundation.mm:360: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm:360: error: 'AVCaptureVideoDataOutput' was not declared in this scope
cap_avfoundation.mm:390: error: 'AVCaptureSessionPresetMedium' was not declared in this scope
cap_avfoundation.mm: In member function 'void CvCaptureCAM::setWidthHeight()':
cap_avfoundation.mm:427: error: 'mCaptureDecompressedVideoOutput' was not declared in this scope
cap_avfoundation.mm: In member function 'virtual double CvCaptureCAM::getProperty(int)':
cap_avfoundation.mm:490: error: 'mCaptureDeviceInput' was not declared in this scope
cap_avfoundation.mm:491: warning: no '-formatDescription' method found
cap_avfoundation.mm:491: warning: (Messages without a matching method signature
cap_avfoundation.mm:491: warning: will be assumed to return 'id' and accept
cap_avfoundation.mm:491: warning: '...' as arguments.)
cap_avfoundation.mm:491: error: cannot convert 'objc_object*' to 'const opaqueCMFormatDescription*' in initialization
cap_avfoundation.mm:505: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm: In member function 'virtual bool CvCaptureCAM::setProperty(int, double)':
cap_avfoundation.mm:545: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:558: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:571: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:584: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm:597: error: 'mCaptureDevice' was not declared in this scope
cap_avfoundation.mm: At global scope:
cap_avfoundation.mm:657: error: expected type-specifier before 'AVCaptureOutput'
cap_avfoundation.mm:657: error: expected `)' before 'AVCaptureOutput'
cap_avfoundation.mm: In function 'void -[CaptureDelegate captureOutput:](CaptureDelegate*, objc_selector*, <type error>)':
cap_avfoundation.mm:657: error: expected `{' before '*' token
cap_avfoundation.mm:657: error: expected unqualified-id before ')' token
cap_avfoundation.mm:657: error: expected constructor, destructor, or type conversion before ')' token
cap_avfoundation.mm:1324: error: expected `@end' at end of input
cap_avfoundation.mm:1324: warning: incomplete implementation of class 'CaptureDelegate'
cap_avfoundation.mm:1324: warning: method definition for '-getOutput' not found
cap_avfoundation.mm:1324: warning: method definition for '-updateImage' not found

来自Aptogo的Robin -我写了你正在谈论的构建脚本。我刚刚尝试用最新的OpenCV主干(svn revision 6769)运行它,它成功完成了。我使用CMake 2.8.5版本。你知道这个脚本是为iOS开发而不是OS X开发构建框架的,对吧?如果你没有安装iOS SDK,可能会遇到问题。

导致构建失败的错误可能是'无法找到'AVCaptureVideoDataOutputSampleBufferDelegate'的协议声明'。该协议在iOS 4和Mac OS 10.7 (Lion)中可用。我猜你是想在没有安装iOS SDK的情况下在雪豹上构建。

编辑为任何人发现这个在SO。原始文章,预构建的OpenCV框架和构建脚本可以在我公司的网站上找到。预构建的框架现在是基于OpenCV svn revision 7017构建的。

最新更新