<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dragly &#187; C++</title>
	<atom:link href="http://dragly.org/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://dragly.org</link>
	<description>It was about time I started writing my own tutorials to share some of the knowledge I&#039;ve picked up from around.</description>
	<lastBuildDate>Mon, 14 May 2012 22:32:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Fixing &#8220;undefined reference to `vtable for &#8230;&#8221;</title>
		<link>http://dragly.org/2010/01/03/fixing-undefined-reference-to-vtable-for/</link>
		<comments>http://dragly.org/2010/01/03/fixing-undefined-reference-to-vtable-for/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 23:00:23 +0000</pubDate>
		<dc:creator>Svenn-Arne Dragly</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[cplusplus]]></category>
		<category><![CDATA[errors]]></category>

		<guid isPermaLink="false">http://svenni.dragly.com/v7/?p=148</guid>
		<description><![CDATA[These annoying errors have been haunting me the last couple of days, so I figured I should share the most common reason for their occurrence. That is in my projects at least. This error is caused because the linker in &#8230; <a href="http://dragly.org/2010/01/03/fixing-undefined-reference-to-vtable-for/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>These annoying errors have been haunting me the last couple of days, so I figured I should share the most common reason for their occurrence. That is in my projects at least.</p>
<p>This error is caused because the linker in gcc is unable to find the functions you have defined in your headers in your actual code. So if you have a header which looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp-qt" style="font-family:monospace;"><span style="color: #006E28;">#ifndef MESH_H</span>
<span style="color: #006E28;">#define MESH_H</span>
&nbsp;
<span style="color: #0057AE;">class</span> Mesh
<span style="color: #006E28;">&#123;</span>
<span style="color: #0057AE;">public</span><span style="color: #006E28;">:</span>
    Mesh<span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
    ~Mesh<span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
    <span style="color: #0057AE;">virtual</span> <span style="color: #0057AE;">void</span> draw<span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span><span style="color: #006E28;">;</span>
<span style="color: #006E28;">&#125;</span><span style="color: #006E28;">;</span>
&nbsp;
<span style="color: #006E28;">#endif // MESH_H</span></pre></div></div>

<p>You must at least have these functions defined in your .cpp file:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp-qt" style="font-family:monospace;"><span style="color: #006E28;">#include &quot;mesh.h&quot;</span>
&nbsp;
Mesh<span style="color: #006E28;">::</span><span style="color: #2B74C7;">Mesh</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&#123;</span>
<span style="color: #006E28;">&#125;</span>
&nbsp;
Mesh<span style="color: #006E28;">::</span><span style="color: #2B74C7;">~Mesh</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&#123;</span>
<span style="color: #006E28;">&#125;</span>
&nbsp;
<span style="color: #0057AE;">void</span> Mesh<span style="color: #006E28;">::</span><span style="color: #2B74C7;">draw</span><span style="color: #006E28;">&#40;</span><span style="color: #006E28;">&#41;</span> <span style="color: #006E28;">&#123;</span>
<span style="color: #006E28;">&#125;</span></pre></div></div>

<p>After this, make sure you clean your compile environment to make sure no object files are being misinterpreted by the compiler. If you are using Qt or a project with a Makefile, you could just run these three commands (the first only applies to Qt projects).</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">qmake
<span style="color: #c20cb9; font-weight: bold;">make</span> clean
<span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://dragly.org/2010/01/03/fixing-undefined-reference-to-vtable-for/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

