<?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[Warum linkt das nicht? PIMPL, undefined reference to vtable]]></title><description><![CDATA[<p>Hoi!<br />
Minimales Beispiel:</p>
<pre><code>#include &lt;memory&gt;

struct A
{
    struct Impl;
    static void deleteImpl(Impl* i);
    std::unique_ptr&lt;Impl, decltype(&amp;deleteImpl)&gt; pimpl;

    A();
};

struct A::Impl
{
    Impl()
    { }

    virtual ~Impl()
    { }

    virtual void foo();
};

struct B : A::Impl
{
    B()
    { }

    virtual void foo() override
    { }
};

void A::deleteImpl(Impl* i)
{
    delete i;
}

A::A()
    : pimpl(new B, &amp;deleteImpl)
{ }

int main()
{
    A a;
}
</code></pre>
<p>Fehlermeldungen - Zeilenangaben stimmen nicht ganz da ich nur einen Teil kopiert habe!</p>
<pre><code>/home/ethon/Code/Projekte/Nano/Nano/build&gt; make -j2
[ 75%] Built target nano
Scanning dependencies of target test
[100%] Building CXX object CMakeFiles/test.dir/main.cpp.o
Linking CXX executable test
CMakeFiles/test.dir/main.cpp.o: In function `A::Impl::Impl()':
/home/ethon/Code/Projekte/Nano/Nano/main.cpp:18: undefined reference to `vtable for A::Impl'
CMakeFiles/test.dir/main.cpp.o: In function `A::Impl::~Impl()':
/home/ethon/Code/Projekte/Nano/Nano/main.cpp:21: undefined reference to `vtable for A::Impl'
CMakeFiles/test.dir/main.cpp.o:(.rodata._ZTI1B[_ZTI1B]+0x10): undefined reference to `typeinfo for A::Impl'
collect2: error: ld returned 1 exit status
make[2]: *** [test] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2
*** Fehler: Beendigungscode 2 ***
</code></pre>
<p>Vielen Dank &amp; Grüße,<br />
Ethon</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/324745/warum-linkt-das-nicht-pimpl-undefined-reference-to-vtable</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 20:59:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/324745.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 30 Mar 2014 20:29:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warum linkt das nicht? PIMPL, undefined reference to vtable on Sun, 30 Mar 2014 20:48:02 GMT]]></title><description><![CDATA[<p>Hoi!<br />
Minimales Beispiel:</p>
<pre><code>#include &lt;memory&gt;

struct A
{
    struct Impl;
    static void deleteImpl(Impl* i);
    std::unique_ptr&lt;Impl, decltype(&amp;deleteImpl)&gt; pimpl;

    A();
};

struct A::Impl
{
    Impl()
    { }

    virtual ~Impl()
    { }

    virtual void foo();
};

struct B : A::Impl
{
    B()
    { }

    virtual void foo() override
    { }
};

void A::deleteImpl(Impl* i)
{
    delete i;
}

A::A()
    : pimpl(new B, &amp;deleteImpl)
{ }

int main()
{
    A a;
}
</code></pre>
<p>Fehlermeldungen - Zeilenangaben stimmen nicht ganz da ich nur einen Teil kopiert habe!</p>
<pre><code>/home/ethon/Code/Projekte/Nano/Nano/build&gt; make -j2
[ 75%] Built target nano
Scanning dependencies of target test
[100%] Building CXX object CMakeFiles/test.dir/main.cpp.o
Linking CXX executable test
CMakeFiles/test.dir/main.cpp.o: In function `A::Impl::Impl()':
/home/ethon/Code/Projekte/Nano/Nano/main.cpp:18: undefined reference to `vtable for A::Impl'
CMakeFiles/test.dir/main.cpp.o: In function `A::Impl::~Impl()':
/home/ethon/Code/Projekte/Nano/Nano/main.cpp:21: undefined reference to `vtable for A::Impl'
CMakeFiles/test.dir/main.cpp.o:(.rodata._ZTI1B[_ZTI1B]+0x10): undefined reference to `typeinfo for A::Impl'
collect2: error: ld returned 1 exit status
make[2]: *** [test] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2
*** Fehler: Beendigungscode 2 ***
</code></pre>
<p>Vielen Dank &amp; Grüße,<br />
Ethon</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2391931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2391931</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sun, 30 Mar 2014 20:48:02 GMT</pubDate></item><item><title><![CDATA[Reply to Warum linkt das nicht? PIMPL, undefined reference to vtable on Sun, 30 Mar 2014 21:20:32 GMT]]></title><description><![CDATA[<p>In Zeile 20, meinten Sie:</p>
<pre><code class="language-cpp">virtual void foo() = 0;
</code></pre>
<p>?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2391941</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2391941</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Sun, 30 Mar 2014 21:20:32 GMT</pubDate></item><item><title><![CDATA[Reply to Warum linkt das nicht? PIMPL, undefined reference to vtable on Sun, 30 Mar 2014 21:35:25 GMT]]></title><description><![CDATA[<p>Ahhh scheiße. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Hat man davon wenn man nur noch D programmiert hat.<br />
Vielen Dank.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2391943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2391943</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Sun, 30 Mar 2014 21:35:25 GMT</pubDate></item></channel></rss>