Results 1 to 6 of 6

Thread: QT Unit Testing moc problem "unresolved external symbol" for QMetaObject

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2015
    Posts
    52
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QT Unit Testing moc problem "unresolved external symbol" for QMetaObject

    I'm trying to add unit tests to a project of mine for the first time.

    I can run mock tests alright (without using my project's classes) and run the application alright. But if I instantiate objects from the project I get an unresolved external symbol of the QMetaObject. If I recall correctly, this means the moc of the object isn't being included on the project.

    How do I fix this? I have the same issue using googletests. The guide also doesn't help on this. I've tried installing the qt unit testing plugin, same result.

    I've uploaded a mock project that follows the same structure that I'm using in the aforementioned project, fetch it here: https://github.com/quimnuss/QtUnitTestingTest

    I'm using a static build of qt on windows, but I guess that's irrellevant. Using QtCreator as IDE and NMAke build.

    I've also tried add the HelloWorld.lib, but taking a look at the Makefile.release it isn't used.

    Somebody has an idea of what I'm doing wrong?

    Here's the unit testing .pro:
    Qt Code:
    1. QT += widgets network testlib
    2.  
    3. TARGET = tst_someunittesttest
    4. CONFIG += console
    5. CONFIG -= app_bundle
    6.  
    7. TEMPLATE = app
    8.  
    9. INCLUDEPATH += $$PWD/../HelloWorld
    10.  
    11. include($$PWD/../HelloWorld/helloworldCommon.pri)
    12.  
    13. LIBS += -L"$$OUT_PWD/../HelloWorld/release"
    14. LIBS += -lHelloWorld
    15.  
    16. message("Searching libs here $$LIBS")
    17.  
    18. SOURCES += tst_someunittesttest.cpp
    19. DEFINES += SRCDIR=\\\"$$PWD/\\\"
    To copy to clipboard, switch view to plain text mode 

    The first error's complete message:

    Qt Code:
    1. tst_someunittesttest.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl HelloWorld::metaObject(void)const " (?metaObject@HelloWorld@@UEBAPEBUQMetaObject@@XZ)
    To copy to clipboard, switch view to plain text mode 
    Last edited by quimnuss; 6th January 2017 at 16:53.

Similar Threads

  1. Replies: 13
    Last Post: 6th May 2019, 23:02
  2. Replies: 4
    Last Post: 9th May 2016, 12:30
  3. Replies: 1
    Last Post: 25th February 2016, 17:17
  4. Replies: 4
    Last Post: 5th January 2011, 15:51
  5. Unresolved external symbol "staticMetaObject"
    By sr71 in forum Qt Programming
    Replies: 5
    Last Post: 29th June 2010, 23:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.