Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Google test and QObject derived object. Errors

    General and Desktop
    3
    8
    2412
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      Kofr last edited by

      I get errors when trying testing with Google Test the QObject derived class - QCat test class.

      undefined reference to `QCat::QCat(QObject*)'
      
      undefined reference to `vtable for QCat'
      

      the code:
      GitHub

      I Include the QCat headers from main project to project for testing in order to create tests fo QCat. All come across is solution to run QMake whick did not work in this case.
      Please help with this issue.

      A 1 Reply Last reply Reply Quote 0
      • K
        Kofr last edited by

        the errors occures here https://github.com/fro0m/Google-Test---Test/blob/master/tests/auto/isvalueok/tst_isvalueok.h
        on the 15 and 16th lines

        1 Reply Last reply Reply Quote 0
        • EatonCode
          EatonCode last edited by EatonCode

          Looking at your partial code...

          Where is qcat.h ?

          Your error out at

          QCat cat;

          Just guessing but is the class name named "QCat" exactly ?

          Or is it "Qcat" or "qCat" ?

          Post qcat.h for more help.

          K 1 Reply Last reply Reply Quote 0
          • K
            Kofr @EatonCode last edited by

            @EatonCode class name is QCat
            full code is acceesible by Link GitHub in first post.

            EatonCode 1 Reply Last reply Reply Quote 0
            • EatonCode
              EatonCode @Kofr last edited by

              @Kofr Hum... I think your still missing QCat.h

              http://www.eatoncode.com/resources/shareit/Screencast_18-06_20-11-2016.mp4

              :)

              1 Reply Last reply Reply Quote 2
              • A
                ambershark @Kofr last edited by ambershark

                @Kofr Usually this happens when your object has not been moc'd. Assuming your google test is a separate build (since they usually are), you do not have the proper build for your object.

                Which is why the solution proposed online is "run qmake". Because normally qmake would properly moc your object.

                Edit: Investigated a bit further, here is your project file for the test:

                
                include(../gtest_dependency.pri)
                
                TEMPLATE = app
                CONFIG += console c++11
                CONFIG -= app_bundle
                CONFIG += thread
                CONFIG += qt
                
                HEADERS +=     tst_isvalueok.h
                
                SOURCES +=     main.cpp
                
                # added this in order to be able to include "cat.h"
                INCLUDEPATH += ../../../src
                

                Nowhere in there does it link to a library containing qcat or include the object for qcat. So as stated earlier, your build is broken. ;)

                If you're still having trouble I can fix it for you later on. I'm not on a system with a development environment right now.

                My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                K 1 Reply Last reply Reply Quote 2
                • K
                  Kofr @ambershark last edited by

                  @ambershark solved

                  
                  include(../gtest_dependency.pri)
                  SRC_DIR = ../../../src
                  
                  TEMPLATE = app
                  CONFIG += console c++11
                  CONFIG -= app_bundle
                  CONFIG += thread
                  CONFIG += qt
                  
                  
                  HEADERS +=     tst_isvalueok.h \
                                 $$SRC_DIR/qcat.h
                  
                  SOURCES +=     main.cpp \
                                 $$SRC_DIR/qcat.cpp
                  
                  
                  # added this in order to be able to include "qcat.h"
                  INCLUDEPATH += $$SRC_DIR
                  
                  ```
                  1 Reply Last reply Reply Quote 0
                  • A
                    ambershark last edited by

                    Good to hear! Don't forget to mark as solved for anyone else with the same problem. :)

                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post