Я пытаюсь интегрировать библиотеку opencv2.2 с создателем Qt4.7 на Mac и сталкиваюсь с проблемами. Большинство из которых я решил в некоторой степени.
Я скачал библиотеку opencv2.2 tar.gz и распаковал ее в подкаталог моей домашней папки, скомпилировав его с помощью CMake, следуя этому руководству для использования статических библиотек. (Я снял флажки с BUILD_SHARED_LIBRARIES и USE_OMIT_FRAME_POINTER и проверил параметры QT)
Мой .pro файл теперь выглядит так:
TARGET = openCVTst1
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
INCLUDEPATH += /opt/local/include /usr/local/include
LIBS += -L/opt/local/lib -lopencv_calib3d -lopencv_contrib -lopencv_features2d \
-lopencv_flann -lopencv_gpu -lopencv_imgproc -lopencv_ml \
-lopencv_objdetect -lopencv_video -lopencv_highgui -lopencv_core
HEADERS += mainwindow.h
FORMS += mainwindow.ui
Теперь я упростил свой тест до использования:
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//MainWindow w;
//w.show();
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 a.exec();
}
в main.cpp, и я все еще получаю те же ошибки. Мой вывод компилятора:
Running build steps for project openCVTst1...
Configuration unchanged, skipping qmake step.
Starting: "/usr/bin/make" -w
make: Entering directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
/usr/bin/qmake -spec /usr/local/Qt4.7/mkspecs/macx-g++ -o Makefile ../openCVTst1/openCVTst1.pro
make: Leaving directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
make: Entering directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
g++ -headerpad_max_install_names -o openCVTst1.app/Contents/MacOS/openCVTst1 main.o mainwindow.o moc_mainwindow.o -F/Library/Frameworks -L/Library/Frameworks -L/opt/local/lib -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_video -lopencv_highgui -lopencv_core -framework QtGui -L/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib -F/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib -framework QtCore
ld: warning: directory '/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib' following -L not found
ld: warning: directory '/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib' following -F not found
Undefined symbols:
"QGLFormat::~QGLFormat()", referenced from:
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
"_glPushMatrix", referenced from:
ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
"_gzclose", referenced from:
_cvReleaseFileStorage in libopencv_core.a(persistence.o)
_cvOpenFileStorage in libopencv_core.a(persistence.o)
_cvOpenFileStorage in libopencv_core.a(persistence.o)
"_glMatrixMode", referenced from:
ViewPort::unsetGL() in libopencv_highgui.a(window_QT.o)
ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
ViewPort::paintEvent(QPaintEvent*) in libopencv_highgui.a(window_QT.o)
"_glShadeModel", referenced from:
ViewPort::initGL() in libopencv_highgui.a(window_QT.o)
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
"_gzrewind", referenced from:
icvRewind(CvFileStorage*) in libopencv_core.a(persistence.o)
"_glEnable", referenced from:
ViewPort::initGL() in libopencv_highgui.a(window_QT.o)
ViewPort::initGL() in libopencv_highgui.a(window_QT.o)
ViewPort::initGL() in libopencv_highgui.a(window_QT.o)
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
"QGLWidget::QGLWidget(QGLFormat const&, QWidget*, QGLWidget const*, QFlags<Qt::WindowType>)", referenced from:
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
"QGLFormat::QGLFormat(QFlags<QGL::FormatOption>, int)", referenced from:
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
"_glHint", referenced from:
ViewPort::initGL() in libopencv_highgui.a(window_QT.o)
ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
"_gzgets", referenced from:
icvGets(CvFileStorage*, char*, int)in libopencv_core.a(persistence.o)
"_glPopMatrix", referenced from:
ViewPort::unsetGL() in libopencv_highgui.a(window_QT.o)
ViewPort::unsetGL() in libopencv_highgui.a(window_QT.o)
ViewPort::paintEvent(QPaintEvent*) in libopencv_highgui.a(window_QT.o)
ViewPort::paintEvent(QPaintEvent*) in libopencv_highgui.a(window_QT.o)
"_glFrustum", referenced from:
ViewPort::icvgluPerspective(double, double, double, double)in libopencv_highgui.a(window_QT.o)
ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
"_gzeof", referenced from:
icvEof(CvFileStorage*) in libopencv_core.a(persistence.o)
"_glLoadIdentity", referenced from:
ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
"QGLWidget::grabFrameBuffer(bool)", referenced from:
ViewPort::saveView() in libopencv_highgui.a(window_QT.o)
"_gzopen", referenced from:
_cvOpenFileStorage in libopencv_core.a(persistence.o)
"_gzputs", referenced from:
icvPuts(CvFileStorage*, char const*)in libopencv_core.a(persistence.o)
make: Leaving directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [openCVTst1.app/Contents/MacOS/openCVTst1] Error 1
The process "/usr/bin/make" exited with code %2.
Error while building project openCVTst1 (target: Desktop)
When executing build step 'Make'
Извините за длинное редактирование