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. Testing app's CPP files
Qt 6.11 is out! See what's new in the release blog

Testing app's CPP files

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 311 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.
  • A Offline
    A Offline
    AkshayFP
    wrote on last edited by
    #1

    I have a project which looks like:

    root.pro
    |- UI.pro
    |   |- systemversion.cpp
    |   `- systemversion.h
    `- TestUI.pro 
        |- test_systemversion.cpp
        `- test_systemversion.h
    

    In TestUI.pro the configuration looks something like this:

    QT += testlib qmltest
    QT -= gui
    
    CONFIG += qt console warn_on depend_includepath testcase qmltestcase
    CONFIG -= app_bundle
    CONFIG += c++17
    
    TEMPLATE = app
    
    INCLUDEPATH += ../UI
    DEPENDPATH += $${INCLUDEPATH}
    
    SOURCES += \
        main.cpp \
        test_systemversion.cpp
    
    HEADERS += \
        test_systemversion.h
    

    When I run the build step I get this error:

    undefined reference to `SystemVersion::SystemVersion(QObject*)
    

    This is happening because I am not able to link the library of UI. I can't actually do that because UI is of type TEMPLATE=app and this doesn't produce a shared object.

    How should I test those files when I can't link the shared object?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Then either add systemversion.cpp to your test sources or build a (static) lib inside UI.pro.
      This lib can then be used to a) link to your test executable and b) together with a main.cpp to create the real executable.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0

      • Login

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