Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

GTest subproject doesn't recognize QList class



  • Hi Guys, sorry if this is a newbie question but I'm not able to make GTest works inside QtCreator.

    I have created a subdir project which looks like:

    TEMPLATE = subdirs
    
    CONFIG += ordered
    
    SUBDIRS += LaMartingala \
        LaMartingalaTests
    

    Then I created my project and inside my I created a .pri file which looks like:

    SOURCES += \
            main.cpp \
            src/finance/instruments/options/CallOption.cpp \
            src/finance/instruments/options/Option.cpp \
            src/service/Service.cpp
    
    HEADERS += \
        src/finance/instruments/options/CallOption.h \
        src/finance/instruments/options/Option.h \
        src/service/Service.h
    
    QT += quickcontrols2 core
    

    Then the test subproject which was created using the GTest template. Its .pro file looks like this:

    include(gtest_dependency.pri)
    include(../LaMartingala/source.pri)
    
    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG += thread
    CONFIG -= qt
    
    QT += core
    
    HEADERS += \
            tst_binomialtree.h
    
    SOURCES += \
            main.cpp
    

    When I compile the GTest project I got an error saying:

    make[1]: *** No rule to make target src/finance/instruments/options/CallOption.cpp', needed byCallOption.o'. Stop.

    make[1]: *** Waiting for unfinished jobs....
    In file included from ../../LaMartingalaProject/LaMartingalaTests/main.cpp:1:
    In file included from ../../LaMartingalaProject/LaMartingalaTests/tst_binomialtree.h:6:
    ../../LaMartingalaProject/LaMartingalaTests/../LaMartingala/src/service/Service.h:4:10: fatal error: 'QList' file not found
    #include <QList>
             ^~~~~~~
    1 error generated.
    make[1]: *** [main.o] Error 1
    make: *** [sub-LaMartingalaTests-make_first-ordered] Error 2
    

    Any idea hot to make this works inside QtCreator please?

    Regards


  • Lifetime Qt Champion

    Hi,

    You have CONFIG -= qt in your .pro file. You should remove that line since you are in fact using Qt.



  • Go it!!! it works

    Thanks


  • Lifetime Qt Champion

    You're welcome !

    Since you have it working now, pleas mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)


Log in to reply