使用以下命令构建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
和其他OFF
图书馆建设很好
现在,我创建了新的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
答案 0 :(得分:0)
我建议您使用brew安装opencv,而不是手动构建或尝试使用已构建的opencv。安装完brew后,请查看brew info opencv
以获取更多信息。
或者,您可以尝试使用完整路径将库添加到项目中。像:
LIBS += /usr/local/lib/libopencv_core.a /usr/local/lib/libopencv_imgproc.a /usr/local/lib/libopencv_highgui.a
如果你的libs中存在一些冲突,这种方法将解决它们。