In my app, there are a couple of functions that I need to use in different threads at different times, and I don't want to copy-paste them everywhere.
So I've made a commonfunctions.cpp
and a commonfunctions.h
, and included them in different places. However, one (out of many) function refuses to work.
The error:
undefined reference to `CommonFunctions::cvMatToQImage(cv::Mat const&)'
commonfunctions.cpp has this function in it:
inline QImage CommonFunctions::cvMatToQImage(const cv::Mat &inMat) {
(....)
}
commonfunctions.h
#ifndef COMMONFUNCTIONS
#define COMMONFUNCTIONS
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QImage>
#include "opencv/cv.h"
#include "opencv/highgui.h"
class CommonFunctions
{
public slots:
inline QImage cvMatToQImage(const cv::Mat &inMat);
void morphImage(cv::Mat threshold);
void detectingMarkers(cv::Mat threshold, cv::Mat frame, cv::Mat roi,
int markerSizeMin, int markerSizeMax, int markerNumber,
int roiX, int roiY, bool tracking,
int &liczbaZgubionych, QString &komunikat);
};
#endif // COMMONFUNCTIONS
The call in kalibracja.cpp
QImage image(commonFunctions.cvMatToQImage(frame));
I didn't forget to #include "commonfunctions.h"
or CommonFunctions commonFunctions;
in kalibracja.cpp
The compiler knows it has to compile all of this. (*.pro file)
SOURCES += main.cpp\
mainwindow.cpp \
kalibracja.cpp \
guiKalibracja.cpp \
commonfunctions.cpp \
analiza.cpp
HEADERS += mainwindow.h \
kalibracja.h \
analiza.h \
commonfunctions.h
when i simply included a *.cpp file it worked, but a) that's not a good way to do things, Ithink, and b) that won't let me include the functions in different threads.
What could be causing this error? What would be the correct way to call the function in question?