<?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[&amp;quot;In function ... undefined reference to ...&amp;quot;]]></title><description><![CDATA[<p>Guten Abend zusammen,</p>
<p>Nach einiger Abwesenheit von C++ möchte ich nun wieder einmal etwas darin machen. Es hat eigentlich prima angefangen, aber jetzt komme ich einfach nicht weiter.<br />
Ich bekomme beim Kompilieren folgende Fehlermeldung:</p>
<pre><code>g++ src/Mainloop.o src/main.o -o overgame -ldl -llua -Llua/lua/src -Ilua/lua/src -lSDL -lSDLmain -ISDL/include -LSDL/build/.libs
src/Mainloop.o: In function `Mainloop::update()':
Mainloop.cpp:(.text+0x193): undefined reference to `LogicLoopable::update()'
src/Mainloop.o: In function `Mainloop::draw()':
Mainloop.cpp:(.text+0x1b2): undefined reference to `GraphicLoopable::draw()'
collect2: Fehler: ld gab 1 als Ende-Status zurück
</code></pre>
<p>Bin jedoch auch nach langem Googlen (sitze schon seit Stunden an diesem Problem) nicht weitergekommen... Was zum Henker habe ich übersehen?<br />
Vielen Dank schon im Voraus!</p>
<pre><code>// Loopable.hpp
#ifndef _LOOPABLE_HPP
#define _LOOPABLE_HPP

#ifdef DREAMCAST
#include &lt;kos.h&gt;
#endif

enum LoopableType {
  LOGIC, GRAPHIC, LOGIC_GRAPHIC
};

class Loopable {
public:
  const LoopableType loopableType;
  virtual ~Loopable(){}
};

class LogicLoopable : public Loopable {
public:
  void update();
  virtual ~LogicLoopable(){}
};

class GraphicLoopable : public Loopable {
public:
  void draw();
  virtual ~GraphicLoopable(){}
};
#endif /* _LOOPABLE_HPP */
</code></pre>
<pre><code>// Mainloop.hpp
#ifndef _MAINLOOP_HPP
#define _MAINLOOP_HPP

#ifdef DREAMCAST
#include &lt;kos.h&gt;
#endif

#include &lt;SDL.h&gt;
#include &lt;vector&gt;
#include &quot;Loopable.hpp&quot;

class Loopable;
class GraphicLoopable;
class LogicLoopable;

class Mainloop {
public:
  Mainloop();
  ~Mainloop();
  int registerLoopable(Loopable* loopable);
  void deregisterLoopable(int id);
  void switchLoopable(int id);
private:
  LogicLoopable *activeLogicLoopable;
  GraphicLoopable *activeGraphicLoopable;
  std::vector&lt;Loopable*&gt; loopables;
  void update();
  void draw();

  int oldticks, t, dt;
  int since();
  void runCircles();
};

#endif /* _MAINLOOP_HPP */
</code></pre>
<pre><code>// Mainloop.cpp
#include &quot;Mainloop.hpp&quot;
#include &quot;Loopable.hpp&quot;

Mainloop::Mainloop() {
  oldticks = SDL_GetTicks();
  dt = 10;
  t = 0;
}

int Mainloop::registerLoopable(Loopable* loopable) {
  loopables.push_back(loopable);
  return loopables.size() - 1;
}

void Mainloop::deregisterLoopable(int id) {
  loopables.erase(loopables.begin()+id);
}

void Mainloop::switchLoopable(int id) {
  Loopable* candidate = loopables.at(id);
  LoopableType t = candidate-&gt;loopableType;
  if(t == LOGIC) {
    activeLogicLoopable = (LogicLoopable*) candidate;
  }
  else if(t == GRAPHIC) {
    activeGraphicLoopable = (GraphicLoopable*) candidate;
  } else {
    activeLogicLoopable = (LogicLoopable*) candidate;
    activeGraphicLoopable = (GraphicLoopable*) candidate;
  }
}

void Mainloop::update() {
  activeLogicLoopable-&gt;update();
}

void Mainloop::draw() {
  activeGraphicLoopable-&gt;draw();
}

int Mainloop::since() {
  int newticks = SDL_GetTicks();
  int ticks = newticks - oldticks;
  oldticks = newticks;
  return ticks;
}

void Mainloop::runCircles() {
  while(true) {
    t += since();
    for(int i=0;i&lt;t/dt;i++) {
      update();
    }
    if(t/dt &gt; 0) {
      draw();
      t %= dt;
    }
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/315343/quot-in-function-undefined-reference-to-quot</link><generator>RSS for Node</generator><lastBuildDate>Fri, 31 Jul 2026 01:50:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/315343.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 30 Mar 2013 18:22:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:22:40 GMT]]></title><description><![CDATA[<p>Guten Abend zusammen,</p>
<p>Nach einiger Abwesenheit von C++ möchte ich nun wieder einmal etwas darin machen. Es hat eigentlich prima angefangen, aber jetzt komme ich einfach nicht weiter.<br />
Ich bekomme beim Kompilieren folgende Fehlermeldung:</p>
<pre><code>g++ src/Mainloop.o src/main.o -o overgame -ldl -llua -Llua/lua/src -Ilua/lua/src -lSDL -lSDLmain -ISDL/include -LSDL/build/.libs
src/Mainloop.o: In function `Mainloop::update()':
Mainloop.cpp:(.text+0x193): undefined reference to `LogicLoopable::update()'
src/Mainloop.o: In function `Mainloop::draw()':
Mainloop.cpp:(.text+0x1b2): undefined reference to `GraphicLoopable::draw()'
collect2: Fehler: ld gab 1 als Ende-Status zurück
</code></pre>
<p>Bin jedoch auch nach langem Googlen (sitze schon seit Stunden an diesem Problem) nicht weitergekommen... Was zum Henker habe ich übersehen?<br />
Vielen Dank schon im Voraus!</p>
<pre><code>// Loopable.hpp
#ifndef _LOOPABLE_HPP
#define _LOOPABLE_HPP

#ifdef DREAMCAST
#include &lt;kos.h&gt;
#endif

enum LoopableType {
  LOGIC, GRAPHIC, LOGIC_GRAPHIC
};

class Loopable {
public:
  const LoopableType loopableType;
  virtual ~Loopable(){}
};

class LogicLoopable : public Loopable {
public:
  void update();
  virtual ~LogicLoopable(){}
};

class GraphicLoopable : public Loopable {
public:
  void draw();
  virtual ~GraphicLoopable(){}
};
#endif /* _LOOPABLE_HPP */
</code></pre>
<pre><code>// Mainloop.hpp
#ifndef _MAINLOOP_HPP
#define _MAINLOOP_HPP

#ifdef DREAMCAST
#include &lt;kos.h&gt;
#endif

#include &lt;SDL.h&gt;
#include &lt;vector&gt;
#include &quot;Loopable.hpp&quot;

class Loopable;
class GraphicLoopable;
class LogicLoopable;

class Mainloop {
public:
  Mainloop();
  ~Mainloop();
  int registerLoopable(Loopable* loopable);
  void deregisterLoopable(int id);
  void switchLoopable(int id);
private:
  LogicLoopable *activeLogicLoopable;
  GraphicLoopable *activeGraphicLoopable;
  std::vector&lt;Loopable*&gt; loopables;
  void update();
  void draw();

  int oldticks, t, dt;
  int since();
  void runCircles();
};

#endif /* _MAINLOOP_HPP */
</code></pre>
<pre><code>// Mainloop.cpp
#include &quot;Mainloop.hpp&quot;
#include &quot;Loopable.hpp&quot;

Mainloop::Mainloop() {
  oldticks = SDL_GetTicks();
  dt = 10;
  t = 0;
}

int Mainloop::registerLoopable(Loopable* loopable) {
  loopables.push_back(loopable);
  return loopables.size() - 1;
}

void Mainloop::deregisterLoopable(int id) {
  loopables.erase(loopables.begin()+id);
}

void Mainloop::switchLoopable(int id) {
  Loopable* candidate = loopables.at(id);
  LoopableType t = candidate-&gt;loopableType;
  if(t == LOGIC) {
    activeLogicLoopable = (LogicLoopable*) candidate;
  }
  else if(t == GRAPHIC) {
    activeGraphicLoopable = (GraphicLoopable*) candidate;
  } else {
    activeLogicLoopable = (LogicLoopable*) candidate;
    activeGraphicLoopable = (GraphicLoopable*) candidate;
  }
}

void Mainloop::update() {
  activeLogicLoopable-&gt;update();
}

void Mainloop::draw() {
  activeGraphicLoopable-&gt;draw();
}

int Mainloop::since() {
  int newticks = SDL_GetTicks();
  int ticks = newticks - oldticks;
  oldticks = newticks;
  return ticks;
}

void Mainloop::runCircles() {
  while(true) {
    t += since();
    for(int i=0;i&lt;t/dt;i++) {
      update();
    }
    if(t/dt &gt; 0) {
      draw();
      t %= dt;
    }
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2311078</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311078</guid><dc:creator><![CDATA[zilti]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:22:40 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:28:08 GMT]]></title><description><![CDATA[<p>Du solltest wohl die Methoden LogicLoopable::update() und GraphicLoopable::draw() definieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311079</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:28:08 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:30:17 GMT]]></title><description><![CDATA[<p>Es reicht also nicht, dass diese in der .hpp-Datei sind?<br />
Das soll nämlich bloss ein Interface sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311080</guid><dc:creator><![CDATA[zilti]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:30:17 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:32:50 GMT]]></title><description><![CDATA[<p>zilti schrieb:</p>
<blockquote>
<p>Es reicht also nicht, dass diese in der .hpp-Datei sind?<br />
Das soll nämlich bloss ein Interface sein.</p>
</blockquote>
<p>Doch, aber sobald Du sie irgendwo benutzt, muss sie auch schließlich definiert sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311081</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:32:50 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:34:16 GMT]]></title><description><![CDATA[<p>d.h. ich muss dieses &quot;interface&quot; dummy-mässig implementieren, damit es implementiert ist?</p>
<pre><code>void update(){}
</code></pre>
<p>Korrekt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311083</guid><dc:creator><![CDATA[zilti]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:34:16 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:34:43 GMT]]></title><description><![CDATA[<p>Versuchs?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311084</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:34:43 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:38:31 GMT]]></title><description><![CDATA[<p>Funktioniert nicht. Auch eine implementation</p>
<pre><code>void LogicLoopable::update(){}
</code></pre>
<p>funktioniert nicht.<br />
Wenn ich mir meinen alten Code anschaue funktionierte dort mysteriöserweise sinngemäss</p>
<pre><code>virtual void update() = 0;
</code></pre>
<p>Das bringt hier aber auch nichts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311085</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311085</guid><dc:creator><![CDATA[zilti]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:38:31 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:46:18 GMT]]></title><description><![CDATA[<p>Welche Fehlermeldung kommt denn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311088</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:46:18 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:47:08 GMT]]></title><description><![CDATA[<p>Diese hier:</p>
<p>zilti schrieb:</p>
<blockquote>
<pre><code>g++ src/Mainloop.o src/main.o -o overgame -ldl -llua -Llua/lua/src -Ilua/lua/src -lSDL -lSDLmain -ISDL/include -LSDL/build/.libs
src/Mainloop.o: In function `Mainloop::update()':
Mainloop.cpp:(.text+0x193): undefined reference to `LogicLoopable::update()'
src/Mainloop.o: In function `Mainloop::draw()':
Mainloop.cpp:(.text+0x1b2): undefined reference to `GraphicLoopable::draw()'
collect2: Fehler: ld gab 1 als Ende-Status zurück
</code></pre>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2311089</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311089</guid><dc:creator><![CDATA[zilti]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:47:08 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 18:58:43 GMT]]></title><description><![CDATA[<p>zilti schrieb:</p>
<blockquote>
<p>Diese hier:</p>
<p>zilti schrieb:</p>
<blockquote>
<pre><code>g++ src/Mainloop.o src/main.o -o overgame -ldl -llua -Llua/lua/src -Ilua/lua/src -lSDL -lSDLmain -ISDL/include -LSDL/build/.libs
src/Mainloop.o: In function `Mainloop::update()':
Mainloop.cpp:(.text+0x193): undefined reference to `LogicLoopable::update()'
src/Mainloop.o: In function `Mainloop::draw()':
Mainloop.cpp:(.text+0x1b2): undefined reference to `GraphicLoopable::draw()'
collect2: Fehler: ld gab 1 als Ende-Status zurück
</code></pre>
</blockquote>
</blockquote>
<p>Und die beiden Objectfiles hast du auch neu gebaut?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311091</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sat, 30 Mar 2013 18:58:43 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;In function ... undefined reference to ...&amp;quot; on Sat, 30 Mar 2013 19:06:34 GMT]]></title><description><![CDATA[<p>Phew, nach einem &quot;make clean&quot; hat das mit den virtuals tatsächlich funktioniert....<br />
EDIT: Gerade gesehen, dass du auf die selbe Idee gekommen bist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Vielen dank nochmal für die Hilfe.<br />
Ich brauche ne Gummiente hier auf dem Tisch...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2311092</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2311092</guid><dc:creator><![CDATA[zilti]]></dc:creator><pubDate>Sat, 30 Mar 2013 19:06:34 GMT</pubDate></item></channel></rss>