PDA

View Full Version : Compiler error with qtcreator and qtestlib



azmeuk
15th November 2011, 12:06
Hi,
In order to debug my current Qt project, I've created a second project containing my test classes and I have some issue with compilation :

make: *** No rule to make target « ../git-cpim-/tests/mihmaptest.moc », needed by « mihmaptest.o ». Stop.

My Test class, my main and my .pro are quite basic.

#include <QObject>
#include <QtTest/QtTest>

class MihMapTest : public QObject{
Q_OBJECT

private slots:
void testFlux(){ QCOMPARE(0,0); }
};
#include "mihmaptest.moc"

int main(int argc, char* argv[]){
QApplication app(argc, argv);
MihMapTest hmaptest;
QTest::qExec(&hmaptest, argc, argv);
return 0;
}

QT += core gui opengl testlib
QT -= gui

TARGET = CPIMTest
CONFIG += console qtestlib

TEMPLATE = app

QMAKE_CXXFLAGS += -DHAVE_CONFIG_H

SOURCES += tests/main.cpp \
tests/mihmaptest.cpp

HEADERS += model/mihmap.h

What did I do wrong ?
Thanks for your help.

MarekR22
15th November 2011, 12:37
make complains that it can't find: ../git-cpim-/tests/mihmaptest.moc file.
This file is auto-generated from header file. Since you have no header file for MihMapTest make simple cheat and add source file (mihmaptest.cpp) as a header in project file.

HEADERS += tests/mihmaptest.cpp


Anyway my solution is a hack. Your code/project should work (at least something similar is working for me), maybe you should first try clean project and try build it again.

Spitfire
15th November 2011, 15:12
Running qmake should help if there's anything wrong with the moc files.