PDA

View Full Version : undefined reference to `cvCreateCameraCapture'



musa_yilmaz
12th February 2010, 16:51
hi, i am new at qt, i installed opencv, and i want to make i simple example like capturing a frame from webcam. i wrote the first line but it gave error. so i cant continue.

codes in my main class is :

#include <QtGui/QApplication>
#include "mainwindow.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv/cxcore.h"

CvCapture* myCap;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
myCap = cvCaptureFromCAM(0);
return a.exec();
}


it gives everytime same error what should i do ?
"undefined reference to `cvCreateCameraCapture'"

ComaWhite
13th February 2010, 01:44
You need to link to the OpenCV libraries.

musa_yilmaz
13th February 2010, 09:53
hmm thanks, how can i do it ?

Lykurg
13th February 2010, 09:58
Use your pro file! Something like that (found through simple google-ing):
INCLUDEPATH += "C:\Program Files\OpenCV\cxcore\include" \
"C:\Program Files\OpenCV\cv\include" \
"C:\Program Files\OpenCV\cvaux\include" \
"C:\Program Files\OpenCV\otherlibs\highgui" \
"C:\Program Files\OpenCV\cxcore\include"
win32:LIBS += -L"C:\Program Files\OpenCV\lib"
LIBS += -lcv \
-lcvaux \
-lhighgui \
-lcxcore

musa_yilmaz
13th February 2010, 10:02
thanx my friend, is it possible to be made automaticly ?

Lykurg
13th February 2010, 10:14
? Don't understand you. What should be automatic?

musa_yilmaz
16th February 2010, 16:22
can Qt add this parameters automaticly or every project we have to declare them manually ?

Lykurg
16th February 2010, 16:31
No, you have to add these lines one time at the pro file for every project you start. There is no automatic way to do it.
And I don't know your definition of "work" but this takes only 2 seconds and if you don't start a new project every 5 seconds, It's no big deal. ;)

spirit
16th February 2010, 16:32
you should add new libs manually in pro-file.

musa_yilmaz
16th February 2010, 17:07
thanks i see :) no problem any more :cool:

hezbon
8th August 2012, 14:13
Am using linux and i have downloaded Opencv2.2.0 and i have same problem i cannot see the lib folder in my opencv please any assistance
Use your pro file! Something like that (found through simple google-ing):
INCLUDEPATH += "C:\Program Files\OpenCV\cxcore\include" \
"C:\Program Files\OpenCV\cv\include" \
"C:\Program Files\OpenCV\cvaux\include" \
"C:\Program Files\OpenCV\otherlibs\highgui" \
"C:\Program Files\OpenCV\cxcore\include"
win32:LIBS += -L"C:\Program Files\OpenCV\lib"
LIBS += -lcv \
-lcvaux \
-lhighgui \
-lcxcore

spirit
8th August 2012, 14:14
Did you build it (sources) or you downloaded already built version (binaries)?