<?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[boost::thread t(thread)]]></title><description><![CDATA[<p>Hallo ich bin recht neu in C++ und muss leider schon recht hart einsteigen.<br />
Wenn ich nun dieses Threadbeispiel teste bekomme ich folgenden Fehler.<br />
Kann mir jemand sagen woran das liegt?</p>
<pre><code>/*
#define BOOST_THREAD_USE_LIB
#include &lt;boost/thread.hpp&gt;
#include &lt;iostream&gt;
void wait(int seconds)
{
  std::cout &lt;&lt;&quot; ich warte&quot; &lt;&lt;std::endl;
}
void thread()
{
  for (int i = 0; i &lt; 5; ++i)
  {
    wait(1);
    std::cout &lt;&lt; i &lt;&lt; std::endl;
  }
}
int main()
{
  boost::thread t(thread);
  t.join();
}
</code></pre>
<pre><code>C:\Users\Viktor Gottfried\workspace\startThread1\Debug/../src/startThread.cpp:32: undefined reference to `boost::thread::join()'
C:\Users\Viktor Gottfried\workspace\startThread1\Debug/../src/startThread.cpp:31: undefined reference to `boost::thread::~thread()'
C:\Users\Viktor Gottfried\workspace\startThread1\Debug/../src/startThread.cpp:31: undefined reference to `boost::thread::~thread()'
src\startThread.o: In function `thread&lt;void (*)()&gt;':
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../include/boost/thread/detail/thread.hpp:204: undefined reference to `boost::thread::start_thread()'
collect2: ld returned 1 exit status
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/303007/boost-thread-t-thread</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 00:01:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/303007.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 May 2012 11:10:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to boost::thread t(thread) on Thu, 03 May 2012 11:10:17 GMT]]></title><description><![CDATA[<p>Hallo ich bin recht neu in C++ und muss leider schon recht hart einsteigen.<br />
Wenn ich nun dieses Threadbeispiel teste bekomme ich folgenden Fehler.<br />
Kann mir jemand sagen woran das liegt?</p>
<pre><code>/*
#define BOOST_THREAD_USE_LIB
#include &lt;boost/thread.hpp&gt;
#include &lt;iostream&gt;
void wait(int seconds)
{
  std::cout &lt;&lt;&quot; ich warte&quot; &lt;&lt;std::endl;
}
void thread()
{
  for (int i = 0; i &lt; 5; ++i)
  {
    wait(1);
    std::cout &lt;&lt; i &lt;&lt; std::endl;
  }
}
int main()
{
  boost::thread t(thread);
  t.join();
}
</code></pre>
<pre><code>C:\Users\Viktor Gottfried\workspace\startThread1\Debug/../src/startThread.cpp:32: undefined reference to `boost::thread::join()'
C:\Users\Viktor Gottfried\workspace\startThread1\Debug/../src/startThread.cpp:31: undefined reference to `boost::thread::~thread()'
C:\Users\Viktor Gottfried\workspace\startThread1\Debug/../src/startThread.cpp:31: undefined reference to `boost::thread::~thread()'
src\startThread.o: In function `thread&lt;void (*)()&gt;':
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../include/boost/thread/detail/thread.hpp:204: undefined reference to `boost::thread::start_thread()'
collect2: ld returned 1 exit status
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2207889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207889</guid><dc:creator><![CDATA[larzarus]]></dc:creator><pubDate>Thu, 03 May 2012 11:10:17 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread t(thread) on Thu, 03 May 2012 11:20:20 GMT]]></title><description><![CDATA[<p>Du musst die Boost-Threadbibliothek dazu linken. Aus den Fehlermeldungen nehme ich mal an, dass du GCC benutzt, da machst du dann auf der Kommandozeile etwas ähnliches wie:</p>
<pre><code>g++ -Wall -Wextra beispiel.cpp -lboost_thread -o beispiel
</code></pre>
<p>Das -lbibliothek bindet eine Bibliothek ein. Achte auf die Reihenfolge. Dateien, die von anderen Dateien genutzt werden, müssen hinter diesen stehen. Hier nutzt dein Beispiel Funktionen aus der libboost_thread, also muss dein Beispielcode weiter vorne stehen.</p>
<p>Wenn du eine IDE benutzt, dann übernimmt die das auch bestimmt alles für dich, du musst ihr nur beibringen, welche Bibliotheken sie dazu linken soll. Wie das genau geht, kommt auf die IDE an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2207890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207890</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 03 May 2012 11:20:20 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread t(thread) on Thu, 03 May 2012 12:00:40 GMT]]></title><description><![CDATA[<p>Genau ich nutze GCC und als IDE benutze ich Eclipse.<br />
Aber dort kann ich unter den Buildsettings<br />
Propoerties--&gt;C/C++ Build--&gt;Settings--&gt;Tool Settings--&gt;MinGW C++ Linker<br />
keine Angaben machen.</p>
<p>Oder muss ich das über Libraries machen? Librarie-search Path oder die Librarie direkt angeben?</p>
<p>C:\boost-libs\boost\bin.v2\libs\thread\build\gcc-mingw-4.5.2\release\link-static\threading-multi</p>
<p>funzt nicht!</p>
<p>Thx und MfG</p>
<p>EDIT:<br />
Habe nun zu den Libraries folgendes hinzugefügt:<br />
boost_thread-mgw45-mt-1_48<br />
pthread</p>
<p>Dann erstellt Eclipse mir eine Exe und Kompiliert alles, aber wenn ich das Prgramm ausführen möchte kommmt:</p>
<p>Nothing to build for startThread1</p>
<pre><code>Error starting process.
Cannot run program &quot;C:\Users\Viktor Gottfried\workspace\startThread1\Debug\startThread1.exe&quot;: Launching failed
Cannot run program &quot;C:\Users\Viktor Gottfried\workspace\startThread1\Debug\startThread1.exe&quot;: Launching failed
Cannot run program &quot;C:\Users\Viktor Gottfried\workspace\startThread1\Debug\startThread1.exe&quot;: Launching failed
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2207897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207897</guid><dc:creator><![CDATA[larzarus]]></dc:creator><pubDate>Thu, 03 May 2012 12:00:40 GMT</pubDate></item></channel></rss>