QT Project Build Issue



  • Hi,

    I added cppunit testing framework to test a QT GUI Application. After Adding application project is not building. It is showing undefined errors for Qt components like Qdebug, QPainter etc. If I remove cppunit testing library and Cppunit Macros for testing in the source code of the project, it is building and running fine. Please tell me if anyone has any idea about this issue.

    Thanks in advance
    Ayush


  • Moderators

    You should provide more information: how did you add cppunit library, what did you change, what are the error messages exactly.
    Can you post your PRO file?

    Qt provides a test framework: http://doc.qt.io/qt-5/qtest-overview.html



  • @jsulm
    I added the cpp unit library with add external library wizard of the QT creater, provide the library path and include path of the headers.

    I added the CppUnit Macros in the source code to test one of the methods of class like this
    class sampletest : public CppUnit ::TestCase
    {
    CPPUNIT_TEST_SUITE(sampletest);
    CPPUNIT_TEST(zerotest);
    CPPUNIT_TEST(nonzerotest);
    CPPUNIT_TEST_SUITE_END();

    public:
    void zerotest();
    void nonzerotest ();
    };

    void sampletest :: zerotest()
    {
    MfcCoreConfig mysample;
    CPPUNIT_ASSERT_MESSAGE ("Test Failed", mysample.validateThresholdValue(11.01f) == MAX_MFC_THRESHOLD);

    }

    void sampletest :: nonzerotest()
    {
    MfcCoreConfig mysample;
    CPPUNIT_ASSERT_MESSAGE ("Test Not Passed", mysample.validateThresholdValue(100.01f) == MAX_MFC_THRESHOLD);
    }



  • @jsulm

    My pro file is this

    #-------------------------------------------------

    Project created by QtCreator 2013-07-22T11:37:35

    #-------------------------------------------------

    QT += core gui

    QT += network

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = MFC_Client_App
    TEMPLATE = app

    SOURCES += main.cpp
    mfcclientapp.cpp
    qcustomplot.cpp
    mfcmdiwidget.cpp
    clientsocket.cpp
    MAINCore.cpp
    MfcUIconfiguration.cpp
    MfcCoreConfig.cpp
    sampletest.cpp

    HEADERS += mfcclientapp.h
    qcustomplot.h
    mfcmdiwidget.h
    clientsocket.h
    MAINCore.h
    mistTypes.h
    Packet.h
    MfcCoreConfig.h
    packet.h
    sampletest.h

    FORMS += mfcclientapp.ui

    RESOURCES +=
    resource.qrc

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/x86_64-linux-gnu/release/ -lcppunit
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../usr/lib/x86_64-linux-gnu/debug/ -lcppunit
    else:unix: LIBS += -L$$PWD/../../../../../usr/lib/x86_64-linux-gnu/ -lcppunit

    INCLUDEPATH += $$PWD/../../../../../usr/include/cppunit
    DEPENDPATH += $$PWD/../../../../../usr/include/cppunit



  • @jsulm

    The error message log is this

    Desktop/QT Projects/MFC_Client_App/qcustomplot.cpp:772: error: undefined reference to `QDebug::~QDebug()'

    /Qt/5.5/gcc_64/include/QtCore/qdebug.h:201: error: undefined reference to `QDebug::~QDebug()'

    Qt/5.5/gcc_64/include/QtCore/qmetatype.h:1680: error: undefined reference to `QMetaType::registerNormalizedType(QByteArray const&, void ()(void), void* ()(void, void const*), int, QFlagsQMetaType::TypeFlag, QMetaObject const*)'


  • Moderators

    Did you try to rebuild your project completely?



  • @jsulm

    Yes i tried clean and rebuild but same errors it is showing


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.