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

发布于 2024-12-06 06:33:08 字数 8549 浏览 1 评论 0原文

我的问题:

我正在 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 脚本,可以用 Cmake 编译 OpenCV,并将结果转换为 XCode 框架(我认为):

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

我从 SVN 检查了最新的 OpenCV 源代码并在其上运行了这个脚本。

更多错误

在日志中较早的位置找到了对 cap_avfoundation.mm 的引用。

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

My problem:

I'm using cmake to compile the latest OpenCV from SVN on Mac OS X and it's having an error at the end of the terminal output. I'm not familiar enough with Cmake to really track down the problem. What does it mean?

Here are the last several lines of output:

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"

How did I get here:

I downloaded the Aptogo OpenCV framework from github https://github.com/aptogo/OpenCVForiPhone

This comes with a bash script to compile OpenCV with Cmake, and turn the result into an XCode framework (I think):

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

I checked out the latest OpenCV source from the SVN and ran this script on it.

More Errors

Found reference to cap_avfoundation.mm earlier in the log.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜访吸血鬼 2024-12-13 06:33:08

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

导致构建失败的错误可能是“找不到‘AVCaptureVideoDataOutputSampleBufferDelegate’的协议声明”。此协议适用于 iOS 4 和 Mac OS 10.7 (Lion)。我猜测您正在尝试在未安装 iOS SDK 的情况下在 Snow Leopard 上进行构建。

为在 SO 上找到此内容的其他人进行编辑。原始文章、预构建的 OpenCV 框架和构建脚本可以在我公司的

Robin from Aptogo here - I wrote the build script that you are talking about. I've just tried running it with the latest OpenCV trunk (svn revision 6769) and it completes successfully. I'm using CMake version 2.8.5. You do know that the script is intended to build a framework for iOS development not OS X development, don't you? You may run into problems if you don't have the iOS SDK installed.

The error that is causing the build to fail is probably 'cannot find protocol declaration for 'AVCaptureVideoDataOutputSampleBufferDelegate'. This protocol is available in iOS 4 and Mac OS 10.7 (Lion). I'm guessing that you are trying to build on Snow Leopard without the iOS SDK installed.

EDIT for anyone else finding this on SO. The original article, pre-built OpenCV framework and build script can be found on my company's website. The pre-built framework is now built against OpenCV svn revision 7017.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文