gpt4 book ai didi

opencv - 使用g++进行编译的OpenCV错误(Mountain Lion 10.8)

转载 作者:行者123 更新时间:2023-12-02 16:42:21 25 4
gpt4 key购买 nike

因此,最近我使用自制软件在Mac上构建了OpenCV,并在遇到错误时尝试运行以下来自stackoverflow用户的hello,world ish程序。

这是程序:

#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)配置您自己的项目以使用OpenCV”:http://opencv.willowgarage.com/wiki/InstallGuide

关于opencv - 使用g++进行编译的OpenCV错误(Mountain Lion 10.8),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14067465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com