i made a project using visual studio and opencv ,it worked fine.
however later i thought of adding GUI.
i googled and found abput QT.some how i managed to include libraries and build paths,when i use C fucntions of opencv the program works fine but when i use c++ features of opencv i get following error:-

#include "widget.h"
#include "ui_widget.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include "opencv/cvaux.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
IplImage *in;
QImage imp;
in=cvLoadImage("F:/test.jpg");
cv::VideoCapture cap;
}

ERROR:-
widget.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl cv::VideoCapture::VideoCapture(void)" (??0VideoCapture@cv@@QEAA@XZ) referenced in function "public: __cdecl Widget::Widget(class QWidget *)" (??0Widget@@QEAA@PEAVQWidget@@@Z)

Most likely the problem is compiler mangling names. c++ compilers change function names so that they can be overriden, while c compilers do not because c does not support overiding functions.

The most common way to prevent name mangling is like this

#ifdef __cplusplus
extern c {
#endif
#include "widget.h"
#include "ui_widget.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include "opencv/cvaux.h"
#ifdef __cplusplus
extern }
#endif

You should check your compiler to see if __cplucplus is defined when compiling c++ code. vc++ defines it but I don't know about other compilers.

i am using vc++ compiler in qt creator..this error is killing me..its been 12 hours.. :(

i would like to have clear undeestanding of "including library filesand dlls".
could you suggest some reference regarding that?

You include .h header files, not DLLs. Header files are very simple -- the compiler's preprocessor adds those files to your program in the spot where you have the #include directive. link

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.