1

所以我最近使用自制软件在我的 Mac 上构建了 OpenCV,当我遇到错误时,我尝试运行以下hello,world ish 程序,该程序是我从 stackoverflow 用户那里获得的。

这是程序:

#include "/usr/local/include/opencv/cv.h"
#include "/usr/local/include/opencv/highgui.h"

int main ( int argc, char **argv )
{
  cvNamedWindow( "My Window", 1 );
  IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
  CvFont font;
  double hScale = 1.0;
  double vScale = 1.0;
  int lineWidth = 1;
  cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
              hScale, vScale, 0, lineWidth );
  cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &font,
             cvScalar( 255, 255, 0 ) );
  cvShowImage( "My Window", img );
  cvWaitKey();
  return 0;
}

这是随后的错误:(编译命令是g++ lol.cpp

Undefined symbols for architecture x86_64:
  "_cvCreateImage", referenced from:
      _main in ccxOWdix.o
  "_cvInitFont", referenced from:
      _main in ccxOWdix.o
  "_cvNamedWindow", referenced from:
      _main in ccxOWdix.o
  "_cvPutText", referenced from:
      _main in ccxOWdix.o
  "_cvShowImage", referenced from:
      _main in ccxOWdix.o
  "_cvWaitKey", referenced from:
      _main in ccxOWdix.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

我究竟做错了什么?

4

1 回答 1

0

您需要链接库。在此处查看“4)配置您自己的项目以使用 OpenCV”:http: //opencv.willowgarage.com/wiki/InstallGuide

于 2012-12-28T12:52:44.197 回答