PDA

View Full Version : undefined reference to `compare::searchTwo(QString, QString, QString)'



abrou
31st January 2008, 20:11
Hello, I am getting this error, (Linking error, according to what I have read), but I can't figure out how to fix it.


RoboSearch.cpp: undefined reference to `compare::searchTwo(QString, QString, QString)'

Most people seem to have this trouble when they don't add the .cpp and .h in the .pro file, but I have. I am using Qt 4 on windows with VS C++ 2005 express, and am using VS to build the project.

qmake –project
qmake
make clean
make release

This is the function in the class RoboSearch that is calling a method from another class.


void RoboSearch::Compare()
{
compare *comp = new compare;
comp->show();
compare::searchTwo("B enrichment - MP - km2.xml", "B Enrichment MP 10-10-5.xml", directory);
}

This is the class declartion of compare in compare.h

class compare : public QMainWindow, private Ui::compare
{
Q_OBJECT

public:
compare(QMainWindow *parent = 0);
static void searchTwo(QString protocol1, QString protocol2, QString directory);
};

And for good measure, here is the .pro file.



TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT += xml
CONFIG += console
RC_FILE = RoboSearch.rc

# Input
HEADERS += compare.h DOM.h readme.h RoboDOM.h RoboSearch.h
FORMS += compare.ui readme.ui RoboSearch.ui
SOURCES += compare.cpp DOM.cpp main.cpp readme.cpp RoboDOM.cpp RoboSearch.cpp
RESOURCES += RoboSearch.qrc

I am new to Qt, and fairly new to programming in general.... Any idea what I'm doing wrong? Thanks!

jacek
31st January 2008, 20:22
Where did you implement compare::searchTwo()?

abrou
31st January 2008, 20:24
I implemented it in compare.cpp, which has #include <compare.h>. It doesn't do anything right now except return, because I took everything out to try to narrow this problem down.

jpn
31st January 2008, 21:08
May we see the implementation? Perhaps you forgot compare:: prefix?

abrou
31st January 2008, 21:44
That is exactly what I forgot! thank you very much.