<?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[Was ist hier falsch (C++ und Headerfiles und Makefile)]]></title><description><![CDATA[<p>Hab hier nen kleines Testprogramm geschrieben:</p>
<p>the main.cpp:</p>
<p>#include &lt;stdlib.h&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;</p>
<p>#include &quot;testme.h&quot;</p>
<p>using namespace std;</p>
<p>int main() {</p>
<p>testme *test = new testme(5);</p>
<p>test-&gt;modify(3);</p>
<p>cout &lt;&lt; test-&gt;getVar();</p>
<p>}</p>
<p>-----------------------------------</p>
<p>the testme.cpp:</p>
<p>class testme<br />
{<br />
private: int var;</p>
<p>public:<br />
testme() {<br />
var = 0;<br />
}<br />
testme(int i) {<br />
var = i;<br />
}<br />
void modify(int i) {<br />
var = i;<br />
}<br />
int getVar() {<br />
return var;<br />
}<br />
};</p>
<p>------------------------------</p>
<p>the testme.h :</p>
<p>#ifndef testme_H<br />
#define tesme_H</p>
<p>class testme<br />
{<br />
private: int var;</p>
<p>public:<br />
testme();<br />
testme(int i);<br />
void modify(int i);<br />
int getVar();<br />
};</p>
<p>#endif<br />
------------------------------------------</p>
<p>and the Makefile :</p>
<p>testfile : main.o testme.o<br />
g++ main.o testme.o -o testfile</p>
<p>main.o : main.cpp testme.h<br />
g++ -c main.cpp<br />
testme.o : testme.cpp<br />
g++ -c testme.cpp</p>
<p>clean : rm main.o testme.o</p>
<p>--------------------------------------------<br />
aber es funktioniert nicht.. beim binden am ende kommt folgende Fehlermeldung:</p>
<p>g++ main.o testme.o -o testfile<br />
main.o(.text+0x2d): In function <code>main': : undefined reference to</code>testme::testme(int)'<br />
main.o(.text+0x73): In function <code>main': : undefined reference to</code>testme::modify(int)'<br />
main.o(.text+0x84): In function <code>main': : undefined reference to</code>testme::getVar()'<br />
collect2: ld returned 1 exit status<br />
make: *** [testfile] Error 1</p>
<p>warum??</p>
<p>vielen danke schonmal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118356/was-ist-hier-falsch-c-und-headerfiles-und-makefile</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 09:20:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118356.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Aug 2005 15:22:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Was ist hier falsch (C++ und Headerfiles und Makefile) on Wed, 17 Aug 2005 15:22:10 GMT]]></title><description><![CDATA[<p>Hab hier nen kleines Testprogramm geschrieben:</p>
<p>the main.cpp:</p>
<p>#include &lt;stdlib.h&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;string.h&gt;</p>
<p>#include &quot;testme.h&quot;</p>
<p>using namespace std;</p>
<p>int main() {</p>
<p>testme *test = new testme(5);</p>
<p>test-&gt;modify(3);</p>
<p>cout &lt;&lt; test-&gt;getVar();</p>
<p>}</p>
<p>-----------------------------------</p>
<p>the testme.cpp:</p>
<p>class testme<br />
{<br />
private: int var;</p>
<p>public:<br />
testme() {<br />
var = 0;<br />
}<br />
testme(int i) {<br />
var = i;<br />
}<br />
void modify(int i) {<br />
var = i;<br />
}<br />
int getVar() {<br />
return var;<br />
}<br />
};</p>
<p>------------------------------</p>
<p>the testme.h :</p>
<p>#ifndef testme_H<br />
#define tesme_H</p>
<p>class testme<br />
{<br />
private: int var;</p>
<p>public:<br />
testme();<br />
testme(int i);<br />
void modify(int i);<br />
int getVar();<br />
};</p>
<p>#endif<br />
------------------------------------------</p>
<p>and the Makefile :</p>
<p>testfile : main.o testme.o<br />
g++ main.o testme.o -o testfile</p>
<p>main.o : main.cpp testme.h<br />
g++ -c main.cpp<br />
testme.o : testme.cpp<br />
g++ -c testme.cpp</p>
<p>clean : rm main.o testme.o</p>
<p>--------------------------------------------<br />
aber es funktioniert nicht.. beim binden am ende kommt folgende Fehlermeldung:</p>
<p>g++ main.o testme.o -o testfile<br />
main.o(.text+0x2d): In function <code>main': : undefined reference to</code>testme::testme(int)'<br />
main.o(.text+0x73): In function <code>main': : undefined reference to</code>testme::modify(int)'<br />
main.o(.text+0x84): In function <code>main': : undefined reference to</code>testme::getVar()'<br />
collect2: ld returned 1 exit status<br />
make: *** [testfile] Error 1</p>
<p>warum??</p>
<p>vielen danke schonmal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/854321</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/854321</guid><dc:creator><![CDATA[Confused_]]></dc:creator><pubDate>Wed, 17 Aug 2005 15:22:10 GMT</pubDate></item><item><title><![CDATA[Reply to Was ist hier falsch (C++ und Headerfiles und Makefile) on Wed, 17 Aug 2005 15:31:33 GMT]]></title><description><![CDATA[<p>öhm warum denn gleich 2 mal ?</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-118263-and-start-is-10.html" rel="nofollow">gleiche frage</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/854327</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/854327</guid><dc:creator><![CDATA[shapeless]]></dc:creator><pubDate>Wed, 17 Aug 2005 15:31:33 GMT</pubDate></item></channel></rss>