[Interest] build error qtestlib

Quân Phạm Minh quanpm4186 at gmail.com
Wed Mar 7 19:03:14 CET 2012


I write 2 files teststring.h and teststring.cpp below
*teststring.h*
#ifndef TESTSTRING_H
#define TESTSTRING_H
#include <QtTest/QTest>
class TestString : public QObject
{
    Q_OBJECT
private slots:
    void toUpper();
};
QTEST_MAIN(TestString);
#endif
*teststring.cpp*
#include "teststring.h"
void TestString::toUpper()
{
    QString str = "Hello";
    QVERIFY(str.toUpper() == "HELLO");
}
*CMakeLists.txt*
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
add_executable(mytest teststring.h teststring.cpp)
target_link_libraries(mytest ${QT_LIBRARIES})
but when build, errors of linking appear
Error    1    error LNK2001: unresolved external symbol "public: virtual
struct QMetaObject const * __thiscall TestString::metaObject(void)const "
(?metaObject at TestString@@UBEPBUQMetaObject@@XZ)    teststring.obj    mytest
......
help me fix this bug. thank in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120308/0bdaf835/attachment.html>


More information about the Interest mailing list