c++ - Xcode 中的 OpenCV C++ 错误

标签 c++ xcode opencv header libraries

我已经使用 cmake 构建系统构建了 OpenCV 库,如 here 所述并将 header 、“.a”和“.dylib”文件添加到我的终端 C++ 项目中。但是,当我运行下面的代码(从 http://iphone-cocoa-objectivec.blogspot.com/2009/01/using-opencv-for-mac-os-in-xcode.html 获得)时,它会给我以下错误。有人有什么建议吗?任何帮助将不胜感激。

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>

int main()
{

    //get the image from the directed path
    IplImage* img = cvLoadImage("/Users/somedir/Programming/TestProj/fruits.jpg", 1);

    //create a window to display the image
    cvNamedWindow("picture", 1);

    //show the image in the window
    cvShowImage("picture", img);

    //wait for the user to hit a key
    cvWaitKey(0);

    //delete the image and window
    cvReleaseImage(&img);
    cvDestroyWindow("picture");

    //return
    return 0;
}

错误

Undefined symbols:
  "_cvLoadImage", referenced from:
      _main in main.o
  "_cvNamedWindow", referenced from:
      _main in main.o
  "_cvReleaseImage", referenced from:
      _main in main.o
  "_cvShowImage", referenced from:
      _main in main.o
  "_cvDestroyWindow", referenced from:
      _main in main.o
  "_cvWaitKey", referenced from:
      _main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

最佳答案

避免将 Xcode 与 OpenCV 2.0 一起使用。如果使用 OpenCV,请使用 Windows,同时使用 OpenCV 1.1。这将减少很多头痛。当 2.0/Mac 有更好的文档时,然后过渡到 Mac 平台/2.0 版本。这本书 (O'Reilly) 很好——涵盖了 v1.1。 2.0 的下一部分应该很快就会发布。 1.

关于c++ - Xcode 中的 OpenCV C++ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1843410/

相关文章:

c++ - 摄氏转换表程序

iphone - iOS 将数据从 tableview 传递到新 View

python - 使用 Python opencv 显示识别的形状

c++ - 尝试使用 OpenCV 从图像写入图像时出现 CL_INVALID_KERNEL_ARGS

c++ - 无法在 BackgroundSubtractorMOG2 中设置用户参数

c++ - 为什么 Microsoft 的 C/C++ 编译器允许带有逗号分隔表达式的 if 语句?

c++ - 未调用 Qt 信号槽

objective-c - 全局 NSOperationQueue

swift - 如何在 SwiftUI 中更改 SceneView 3D 对象的背景颜色

python - 我画出图像中最大的轮廓。但是用颜色填充是行不通的。任何的想法??