Hey @all,
i'm trying to compile a simple QtTestLib app, which ends up in a "undefined reference to vtable..." error.
Here is the simple source:
#include <QtTest>
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void firstTest();
};
void TestDemo::initTestCase() {
}
void TestDemo::cleanupTestCase() {
}
void TestDemo::firstTest() {
QVERIFY(1 == 1);
}
QTEST_MAIN(TestDemo)
#include <QtTest>
class TestDemo: public QObject {
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void firstTest();
};
void TestDemo::initTestCase() {
}
void TestDemo::cleanupTestCase() {
}
void TestDemo::firstTest() {
QVERIFY(1 == 1);
}
QTEST_MAIN(TestDemo)
To copy to clipboard, switch view to plain text mode
And here is the corresponding CMakeLists.txt file:
SET(QT_USE_QTMAIN TRUE)
SET(QT_USE_QTTEST TRUE)
INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES(./)
SET(TESTDEMO_SOURCES
main.cpp
)
QT4_AUTOMOC(${TESTDEMO_SOURCES})
ADD_EXECUTABLE(TestDemo ${TESTDEMO_SOURCES} ${TESTDEMO_MOC})
TARGET_LINK_LIBRARIES(TestDemo ${QT_LIBRARIES})
SET(QT_USE_QTMAIN TRUE)
SET(QT_USE_QTTEST TRUE)
INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES(./)
SET(TESTDEMO_SOURCES
main.cpp
)
QT4_AUTOMOC(${TESTDEMO_SOURCES})
ADD_EXECUTABLE(TestDemo ${TESTDEMO_SOURCES} ${TESTDEMO_MOC})
TARGET_LINK_LIBRARIES(TestDemo ${QT_LIBRARIES})
To copy to clipboard, switch view to plain text mode
The error I get is the following:
-- Configuring done
-- Generating done
-- Build files have been written to: build/Debug
Scanning dependencies of target TestDemo
[100%] Building CXX object test/TestDemo/CMakeFiles/TestDemo.dir/main.cpp.obj
Linking CXX executable ..\..\bin\TestDemo.exe
CMakeFiles\TestDemo.dir\main.cpp.obj: In function `TestDemo':
test/TestDemo/main.cpp:4: undefined reference to `vtable for TestDemo'
CMakeFiles\TestDemo.dir\main.cpp.obj: In function `~TestDemo':
test/TestDemo/main.cpp:4: undefined reference to `vtable for TestDemo'
collect2: ld returned 1 exit status
mingw32-make[3]: *** [bin/TestDemo.exe] Error 1
mingw32-make[2]: *** [test/TestDemo/CMakeFiles/TestDemo.dir/all] Error 2
mingw32-make[1]: *** [test/TestDemo/CMakeFiles/TestDemo.dir/rule] Error 2
mingw32-make: *** [TestDemo] Error 2
-- Configuring done
-- Generating done
-- Build files have been written to: build/Debug
Scanning dependencies of target TestDemo
[100%] Building CXX object test/TestDemo/CMakeFiles/TestDemo.dir/main.cpp.obj
Linking CXX executable ..\..\bin\TestDemo.exe
CMakeFiles\TestDemo.dir\main.cpp.obj: In function `TestDemo':
test/TestDemo/main.cpp:4: undefined reference to `vtable for TestDemo'
CMakeFiles\TestDemo.dir\main.cpp.obj: In function `~TestDemo':
test/TestDemo/main.cpp:4: undefined reference to `vtable for TestDemo'
collect2: ld returned 1 exit status
mingw32-make[3]: *** [bin/TestDemo.exe] Error 1
mingw32-make[2]: *** [test/TestDemo/CMakeFiles/TestDemo.dir/all] Error 2
mingw32-make[1]: *** [test/TestDemo/CMakeFiles/TestDemo.dir/rule] Error 2
mingw32-make: *** [TestDemo] Error 2
To copy to clipboard, switch view to plain text mode
Could anybody help me to fix the problem?
Thanks in advance
Best Regards
NoRulez
Bookmarks