0

使用以下命令构建 opencv 静态库:

BUILD_SHARED_LIBS = OFF
build_opencv_core = ON
build_opencv_imgproc = ON
build_opencv_highgui = ON

WITH_FFMPEG = ON
WITH_PNG = ON
WITH_JASPER = ON
WITH_TIFF = ON
WITH_OPENEXR = ON

和其他关

图书馆建设很好

现在,我创建了新的 Qt 项目

INCLUDEPATH += -I/usr/local/include
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui

在 main.cpp

#include <QCoreApplication>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

int main(int argc,char** argv)
{
QCoreApplication a(argc,argv);
CvCapture* capture = cvCaptureFromCam(0);

return a.exec();
}

但是当我构建我的项目时,我得到下一个错误:

Undefined symbols for architecture i386:
"_cvCreateCameraCapture", referenced from:
_main in main.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
Undefined symbols for architecture x86_64:
"_cvCreateCameraCapture", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
lipo: can't open input file: /var/folders/ff/wbcdn98j5nx617_p5vpzq1cm0000gn/T//ccqFaXgY.out (No such file or directory)
make: *** [TestCamera] Error 1

-

lipo -info /usr/local/lib/libopencv_highgui.a
Architectures in the fat file: /usr/local/lib/libopencv_highgui.a are: i386 x86_64
4

1 回答 1

0

我建议您使用brew安装 opencv 而不是手动构建或尝试使用已经构建的。安装 brew 后,请查看brew info opencv一些其他信息。

或者,您可以尝试使用完整路径将库添加到项目中。喜欢:

LIBS += /usr/local/lib/libopencv_core.a /usr/local/lib/libopencv_imgproc.a /usr/local/lib/libopencv_highgui.a

如果您的库中有一些冲突,这种方法将解决它们。

于 2013-06-10T12:30:22.620 回答