Google test and QObject derived object. Errors
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'
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 QMakewhick did not work in this case.
Please help with this issue.
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
EatonCode last edited by EatonCode
Looking at your partial code...
Where is qcat.h ?
Your error out at
Just guessing but is the class name named "QCat" exactly ?
Or is it "Qcat" or "qCat" ?
Post qcat.h for more help.
@EatonCode class name is QCat
full code is acceesible by Link
GitHubin first post.
EatonCode last edited by
@Kofr Hum... I think your still missing QCat.h
@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.
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 ```
Good to hear! Don't forget to mark as solved for anyone else with the same problem. :)