<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Testing app&#x27;s CPP files]]></title><description><![CDATA[<p dir="auto">I have a project which looks like:</p>
<pre><code>root.pro
|- UI.pro
|   |- systemversion.cpp
|   `- systemversion.h
`- TestUI.pro 
    |- test_systemversion.cpp
    `- test_systemversion.h
</code></pre>
<p dir="auto">In <code>TestUI.pro</code>  the configuration looks something like this:</p>
<pre><code>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
</code></pre>
<p dir="auto">When I run the build step I get this error:</p>
<pre><code>undefined reference to `SystemVersion::SystemVersion(QObject*)
</code></pre>
<p dir="auto">This is happening because I am not able to link the library of <code>UI</code>. I can't actually do that because UI is of type <code>TEMPLATE=app</code> and this doesn't produce a shared object.</p>
<p dir="auto">How should I test those files when I can't link the shared object?</p>
]]></description><link>https://forum.qt.io/topic/134944/testing-app-s-cpp-files</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 06:59:08 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/134944.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Mar 2022 00:29:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Testing app&#x27;s CPP files on Thu, 10 Mar 2022 06:09:13 GMT]]></title><description><![CDATA[<p dir="auto">Then either add systemversion.cpp to your test sources or build a (static) lib inside <a href="http://UI.pro" target="_blank" rel="noopener noreferrer nofollow ugc">UI.pro</a>.<br />
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.</p>
]]></description><link>https://forum.qt.io/post/705855</link><guid isPermaLink="true">https://forum.qt.io/post/705855</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Thu, 10 Mar 2022 06:09:13 GMT</pubDate></item></channel></rss>