<?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[Link error in test unit with QOBJECT macro]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">I have created a dll project. This one build without errors.<br />
I want to test this dll so I create a QtTest class.<br />
But when I try to build the unit test .pro I get the following errors :</p>
<pre><code>tst_testsconnection.obj : error LNK2001: symbole externe non résolu "public: virtual void * __cdecl QSerialPort::`scalar deleting destructor'(unsigned int)" (??_GQSerialPort@@UEAAPEAXI@Z)
tst_testsconnection.obj : error LNK2001: symbole externe non résolu "public: virtual void * __cdecl QSerialPort::`vector deleting destructor'(unsigned int)" (??_EQSerialPort@@UEAAPEAXI@Z)

</code></pre>
<p dir="auto">In my Dll I have a class  who uses QSerialPort. But I have no issue on how to fix this link error.<br />
If I remove the QOBJECT macro and the signals/slot part there is no more any link errors.<br />
My dll project was created using QtCreator wizard.</p>
<p dir="auto">Below the .h of my class in the dll :</p>
<pre><code>#ifndef RS232UNIWHEEL_H
#define RS232UNIWHEEL_H

#include "connectionlibrary_global.h"

#include &lt;QObject&gt;
#include &lt;QtSerialPort/QSerialPort&gt;

class CONNECTIONLIBRARYSHARED_EXPORT RS232UniWheel : public QObject
{
    Q_OBJECT

public:
    RS232UniWheel();
    ~RS232UniWheel();
    void open();
    bool isOpen();
    void close();
    void writeList();
    void writeStart();
    void writeStop();
    QByteArray readAll();
    QString getError();

signals:
    void errorOccurred(QSerialPort::SerialPortError error);
    void readyRead();

public slots:
    void readData();
    void handleError(QSerialPort::SerialPortError error);

private :
    QSerialPort m_serial;

};

#endif // RS232UNIWHEEL_H

</code></pre>
<p dir="auto">All these are quite simple usage of Qt code.</p>
<p dir="auto">If anyone has an idea  ??</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/topic/107391/link-error-in-test-unit-with-qobject-macro</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 17:29:26 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/107391.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 02 Oct 2019 14:14:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Link error in test unit with QOBJECT macro on Thu, 03 Oct 2019 07:37:33 GMT]]></title><description><![CDATA[<p dir="auto">Thanks @SGaist. This is solved by change compiler and used Mingw instead of MSVC.</p>
]]></description><link>https://forum.qt.io/post/554155</link><guid isPermaLink="true">https://forum.qt.io/post/554155</guid><dc:creator><![CDATA[CHPOG]]></dc:creator><pubDate>Thu, 03 Oct 2019 07:37:33 GMT</pubDate></item><item><title><![CDATA[Reply to Link error in test unit with QOBJECT macro on Thu, 03 Oct 2019 07:25:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a><br />
I use QtCreator 4.9.2.<br />
I don't really know which compiler I use. I just click on the Rebuild popup menu in the project.<br />
After take a look I used MSVC compiler and want to use Mingw. But when changing to mingw compilation failed, this is an other issue when I want to emit signals I have a  undefined reference</p>
<p dir="auto">/ConnectionLibrary/RS232UniWheel.cpp:16: undefined reference to `RS232UniWheel::errorOccurred(QSerialPort::SerialPortError)'</p>
<pre><code>void RS232UniWheel::handleError(QSerialPort::SerialPortError error) {
    emit errorOccurred(error);
}
</code></pre>
]]></description><link>https://forum.qt.io/post/554154</link><guid isPermaLink="true">https://forum.qt.io/post/554154</guid><dc:creator><![CDATA[CHPOG]]></dc:creator><pubDate>Thu, 03 Oct 2019 07:25:53 GMT</pubDate></item><item><title><![CDATA[Reply to Link error in test unit with QOBJECT macro on Wed, 02 Oct 2019 17:29:18 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">What compiler are you using ?<br />
What version of Qt are you building your test with ?</p>
]]></description><link>https://forum.qt.io/post/554070</link><guid isPermaLink="true">https://forum.qt.io/post/554070</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 02 Oct 2019 17:29:18 GMT</pubDate></item><item><title><![CDATA[Reply to Link error in test unit with QOBJECT macro on Wed, 02 Oct 2019 15:04:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a><br />
Yes I try but no more successfull. And the link error is on the destructor of QSerialPort not Rs232UniWhelll one.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pl45m4">@<bdi>Pl45m4</bdi></a><br />
Yes I had QT += serialport in my .pro file.<br />
Before I forgot to add it but I had  much more link error.<br />
All functions/slots are implemented in my cpp files.<br />
And I also try to delete the build directory and do a new build.</p>
]]></description><link>https://forum.qt.io/post/554034</link><guid isPermaLink="true">https://forum.qt.io/post/554034</guid><dc:creator><![CDATA[CHPOG]]></dc:creator><pubDate>Wed, 02 Oct 2019 15:04:12 GMT</pubDate></item><item><title><![CDATA[Reply to Link error in test unit with QOBJECT macro on Wed, 02 Oct 2019 14:38:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chpog">@<bdi>CHPOG</bdi></a> said in <a href="/post/554019">Link error in test unit with QOBJECT macro</a>:</p>
<pre><code>tst_testsconnection.obj : error LNK2001: symbole externe non résolu "public: virtual void * __cdecl QSerialPort::`scalar deleting destructor'(unsigned int)" (??_GQSerialPort@@UEAAPEAXI@Z)
tst_testsconnection.obj : error LNK2001: symbole externe non résolu "public: virtual void * __cdecl QSerialPort::`vector deleting destructor'(unsigned int)" (??_EQSerialPort@@UEAAPEAXI@Z)
</code></pre>
<p dir="auto">Is <code>QtSerialPort</code> included in your project file?<br />
(<a href="https://stackoverflow.com/questions/20044185/qt-linker-error-when-adding-class-to-basic-qt-gui-application" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/20044185/qt-linker-error-when-adding-class-to-basic-qt-gui-application</a>)</p>
<p dir="auto">Check if all functions / slots are implemented in your cpp files.<br />
Try a cleanup and qmake / build again</p>
]]></description><link>https://forum.qt.io/post/554026</link><guid isPermaLink="true">https://forum.qt.io/post/554026</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Wed, 02 Oct 2019 14:38:43 GMT</pubDate></item><item><title><![CDATA[Reply to Link error in test unit with QOBJECT macro on Wed, 02 Oct 2019 14:33:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chpog">@<bdi>CHPOG</bdi></a> said in <a href="/post/554019">Link error in test unit with QOBJECT macro</a>:</p>
<blockquote>
<p dir="auto">~RS232UniWheel();</p>
</blockquote>
<p dir="auto">Did you actually implement this ctor?</p>
]]></description><link>https://forum.qt.io/post/554024</link><guid isPermaLink="true">https://forum.qt.io/post/554024</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Wed, 02 Oct 2019 14:33:44 GMT</pubDate></item></channel></rss>