Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Google test and QObject derived object. Errors

Google test and QObject derived object. Errors

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.8k Views
  • 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 Offline
    K Offline
    Kofr
    wrote on 20 Nov 2016, 23:31 last edited by
    #1

    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 21 Nov 2016, 02:44
    0
    • K Offline
      K Offline
      Kofr
      wrote on 20 Nov 2016, 23:33 last edited by
      #2

      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
      0
      • E Offline
        E Offline
        EatonCode
        wrote on 20 Nov 2016, 23:45 last edited by EatonCode
        #3

        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 20 Nov 2016, 23:56
        0
        • E EatonCode
          20 Nov 2016, 23:45

          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 Offline
          K Offline
          Kofr
          wrote on 20 Nov 2016, 23:56 last edited by
          #4

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

          E 1 Reply Last reply 21 Nov 2016, 00:07
          0
          • K Kofr
            20 Nov 2016, 23:56

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

            E Offline
            E Offline
            EatonCode
            wrote on 21 Nov 2016, 00:07 last edited by
            #5

            @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
            2
            • K Kofr
              20 Nov 2016, 23:31

              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 Offline
              A Offline
              ambershark
              wrote on 21 Nov 2016, 02:44 last edited by ambershark
              #6

              @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 21 Nov 2016, 20:24
              2
              • A ambershark
                21 Nov 2016, 02:44

                @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.

                K Offline
                K Offline
                Kofr
                wrote on 21 Nov 2016, 20:24 last edited by
                #7

                @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
                0
                • A Offline
                  A Offline
                  ambershark
                  wrote on 21 Nov 2016, 20:43 last edited by
                  #8

                  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
                  0

                  2/8

                  20 Nov 2016, 23:33

                  topic:navigator.unread, 6
                  • Login

                  • Login or register to search.
                  2 out of 8
                  • First post
                    2/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved