<?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 will nicht funktionieren]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>folgendes Problem: Ich habe 2 while-Schleifen mit dem gleichen Abbruchkriterium. Bei der einen handelt es sich um eine permanente Ausgabe auf das Terminal, bei der anderen um Keyboard-Eingaben, die jederzeit erfolgen können (sollen). Deswegen 2, weil ihr jeweiliger Code nicht hintereinander ausgeführt werden soll, sondern gleichzeitig.<br />
Nach einigem googeln habe ich herausgefunden, dass ich 2 Threads benötige. Also hab ich Boost heruntergeladen.</p>
<p>Bereits unabhängig von meinem eigentlichen Problem: Selbst <a href="http://www.highscore.de/cpp/boost/multithreading.html" rel="nofollow">diese Codebeispiele</a> funktionieren nicht. Das sagt g++ zum ersten Beispiel:</p>
<blockquote>
<p>g++ tmp.cpp -I ../../../Library/boost_1_45_0/<br />
Undefined symbols:<br />
&quot;boost::this_thread::sleep(boost::posix_time::ptime const&amp;)&quot;, referenced from:<br />
void boost::this_thread::sleep<a href="boost::posix%5C_time::seconds" rel="nofollow">boost::posix\_time::seconds</a>(boost::posix_time::seconds const&amp;)in ccffrXiI.o<br />
&quot;boost::detail::thread_data_base::~thread_data_base()&quot;, referenced from:<br />
boost::detail::thread_data&lt;void (<em>)()&gt;::~thread_data()in ccffrXiI.o<br />
boost::detail::thread_data&lt;void (</em>)()&gt;::~thread_data()in ccffrXiI.o<br />
&quot;vtable for boost::detail::thread_data_base&quot;, referenced from:<br />
boost::detail::thread_data_base::thread_data_base()in ccffrXiI.o<br />
&quot;boost::thread::join()&quot;, referenced from:<br />
_main in ccffrXiI.o<br />
&quot;typeinfo for boost::detail::thread_data_base&quot;, referenced from:<br />
typeinfo for boost::detail::thread_data&lt;void (<em>)()&gt;in ccffrXiI.o<br />
&quot;boost::thread::~thread()&quot;, referenced from:<br />
_main in ccffrXiI.o<br />
_main in ccffrXiI.o<br />
&quot;boost::thread::start_thread()&quot;, referenced from:<br />
boost::thread::thread&lt;void (</em>)()&gt;(void (<em>)(), boost::disable_if&lt;boost::is_convertible&lt;void (</em>&amp;)(), boost::detail::thread_move_t&lt;void (<em>)()&gt; &gt;, boost::thread::dummy</em>&gt;::type)in ccffrXiI.o<br />
ld: symbol(s) not found<br />
collect2: ld returned 1 exit status</p>
</blockquote>
<p>Wie man sieht, macht der Linker Probleme. Der Pfad zu boost ist jedenfalls Korrekt. Aber das &quot;nur nebenbei&quot;. Und hier meine eigentliche Ausgabe nach Kompilierversuch:</p>
<blockquote>
<p>g++ spielesammlung.cpp -I ../../../../Library/boost_1_45_0/ -lcurses<br />
In file included from spielesammlung.cpp:5:<br />
pong/pong.hpp: In member function ‘void pong::play()’:<br />
pong/pong.hpp:92: error: no matching function for call to ‘boost::thread::thread(&lt;unresolved overloaded function type&gt;)’<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:215: note: candidates are: boost::thread::thread(boost::detail::thread_move_t<a href="boost::thread" rel="nofollow">boost::thread</a>)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:201: note: boost::thread::thread(F, typename boost::disable_if&lt;boost::is_convertible&lt;T&amp;, boost::detail::thread_move_t&lt;T&gt; &gt;, boost::thread::dummy*&gt;::type) [with F = void (pong::<em>)()]<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:154: note: boost::thread::thread()<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:122: note: boost::thread::thread(boost::detail::thread_data_ptr)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:113: note: boost::thread::thread(boost::thread&amp;)<br />
pong/pong.hpp:94: error: no matching function for call to ‘boost::thread::thread(&lt;unresolved overloaded function type&gt;)’<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:215: note: candidates are: boost::thread::thread(boost::detail::thread_move_t<a href="boost::thread" rel="nofollow">boost::thread</a>)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:201: note: boost::thread::thread(F, typename boost::disable_if&lt;boost::is_convertible&lt;T&amp;, boost::detail::thread_move_t&lt;T&gt; &gt;, boost::thread::dummy</em>&gt;::type) [with F = void (pong::*)()]<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:154: note: boost::thread::thread()<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:122: note: boost::thread::thread(boost::detail::thread_data_ptr)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:113: note: boost::thread::thread(boost::thread&amp;)</p>
</blockquote>
<p>Die Fehlermeldung bezieht sich auf folgenden Code (innerhalb einer Klasse):</p>
<pre><code class="language-cpp">void ball_moves(){
  while(A.get_lifes()!=0 &amp;&amp; B.get_lifes()!=0){
    //einige Zeilen
  }
}

void key_events(){
  int c = 0;
  while(A.get_lifes()!=0 &amp;&amp; B.get_lifes()!=0){
    //einige Zeilen
  }  
} 

void play(){
  boost::thread t1(ball_moves); 
  t1.join(); 
  boost::thread t2(key_events);
  t2.join();
}
</code></pre>
<p>Die betreffenden Zeilen 92 und 94 aus der Fehlermeldung sind in diesem Fall 15 und 17. Offensichtlich gibt es keine passenden Konstruktor von boost::thread::thread für mein Vorhaben. Aber warum nicht? Was unterscheidet meinen Code vom Codebeispiel (und Linkerprobleme gibt es hier komischerweise auch nicht??)?</p>
<p>Ich bin Neuling, was Boost angeht: Was mache ich falsch? (Und schon mal vielen Dank im Voraus :))</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/282054/boost-thread-will-nicht-funktionieren</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 09:37:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/282054.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 13 Feb 2011 01:16:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 01:16:54 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>folgendes Problem: Ich habe 2 while-Schleifen mit dem gleichen Abbruchkriterium. Bei der einen handelt es sich um eine permanente Ausgabe auf das Terminal, bei der anderen um Keyboard-Eingaben, die jederzeit erfolgen können (sollen). Deswegen 2, weil ihr jeweiliger Code nicht hintereinander ausgeführt werden soll, sondern gleichzeitig.<br />
Nach einigem googeln habe ich herausgefunden, dass ich 2 Threads benötige. Also hab ich Boost heruntergeladen.</p>
<p>Bereits unabhängig von meinem eigentlichen Problem: Selbst <a href="http://www.highscore.de/cpp/boost/multithreading.html" rel="nofollow">diese Codebeispiele</a> funktionieren nicht. Das sagt g++ zum ersten Beispiel:</p>
<blockquote>
<p>g++ tmp.cpp -I ../../../Library/boost_1_45_0/<br />
Undefined symbols:<br />
&quot;boost::this_thread::sleep(boost::posix_time::ptime const&amp;)&quot;, referenced from:<br />
void boost::this_thread::sleep<a href="boost::posix%5C_time::seconds" rel="nofollow">boost::posix\_time::seconds</a>(boost::posix_time::seconds const&amp;)in ccffrXiI.o<br />
&quot;boost::detail::thread_data_base::~thread_data_base()&quot;, referenced from:<br />
boost::detail::thread_data&lt;void (<em>)()&gt;::~thread_data()in ccffrXiI.o<br />
boost::detail::thread_data&lt;void (</em>)()&gt;::~thread_data()in ccffrXiI.o<br />
&quot;vtable for boost::detail::thread_data_base&quot;, referenced from:<br />
boost::detail::thread_data_base::thread_data_base()in ccffrXiI.o<br />
&quot;boost::thread::join()&quot;, referenced from:<br />
_main in ccffrXiI.o<br />
&quot;typeinfo for boost::detail::thread_data_base&quot;, referenced from:<br />
typeinfo for boost::detail::thread_data&lt;void (<em>)()&gt;in ccffrXiI.o<br />
&quot;boost::thread::~thread()&quot;, referenced from:<br />
_main in ccffrXiI.o<br />
_main in ccffrXiI.o<br />
&quot;boost::thread::start_thread()&quot;, referenced from:<br />
boost::thread::thread&lt;void (</em>)()&gt;(void (<em>)(), boost::disable_if&lt;boost::is_convertible&lt;void (</em>&amp;)(), boost::detail::thread_move_t&lt;void (<em>)()&gt; &gt;, boost::thread::dummy</em>&gt;::type)in ccffrXiI.o<br />
ld: symbol(s) not found<br />
collect2: ld returned 1 exit status</p>
</blockquote>
<p>Wie man sieht, macht der Linker Probleme. Der Pfad zu boost ist jedenfalls Korrekt. Aber das &quot;nur nebenbei&quot;. Und hier meine eigentliche Ausgabe nach Kompilierversuch:</p>
<blockquote>
<p>g++ spielesammlung.cpp -I ../../../../Library/boost_1_45_0/ -lcurses<br />
In file included from spielesammlung.cpp:5:<br />
pong/pong.hpp: In member function ‘void pong::play()’:<br />
pong/pong.hpp:92: error: no matching function for call to ‘boost::thread::thread(&lt;unresolved overloaded function type&gt;)’<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:215: note: candidates are: boost::thread::thread(boost::detail::thread_move_t<a href="boost::thread" rel="nofollow">boost::thread</a>)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:201: note: boost::thread::thread(F, typename boost::disable_if&lt;boost::is_convertible&lt;T&amp;, boost::detail::thread_move_t&lt;T&gt; &gt;, boost::thread::dummy*&gt;::type) [with F = void (pong::<em>)()]<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:154: note: boost::thread::thread()<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:122: note: boost::thread::thread(boost::detail::thread_data_ptr)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:113: note: boost::thread::thread(boost::thread&amp;)<br />
pong/pong.hpp:94: error: no matching function for call to ‘boost::thread::thread(&lt;unresolved overloaded function type&gt;)’<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:215: note: candidates are: boost::thread::thread(boost::detail::thread_move_t<a href="boost::thread" rel="nofollow">boost::thread</a>)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:201: note: boost::thread::thread(F, typename boost::disable_if&lt;boost::is_convertible&lt;T&amp;, boost::detail::thread_move_t&lt;T&gt; &gt;, boost::thread::dummy</em>&gt;::type) [with F = void (pong::*)()]<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:154: note: boost::thread::thread()<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:122: note: boost::thread::thread(boost::detail::thread_data_ptr)<br />
../../../../Library/boost_1_45_0/boost/thread/detail/thread.hpp:113: note: boost::thread::thread(boost::thread&amp;)</p>
</blockquote>
<p>Die Fehlermeldung bezieht sich auf folgenden Code (innerhalb einer Klasse):</p>
<pre><code class="language-cpp">void ball_moves(){
  while(A.get_lifes()!=0 &amp;&amp; B.get_lifes()!=0){
    //einige Zeilen
  }
}

void key_events(){
  int c = 0;
  while(A.get_lifes()!=0 &amp;&amp; B.get_lifes()!=0){
    //einige Zeilen
  }  
} 

void play(){
  boost::thread t1(ball_moves); 
  t1.join(); 
  boost::thread t2(key_events);
  t2.join();
}
</code></pre>
<p>Die betreffenden Zeilen 92 und 94 aus der Fehlermeldung sind in diesem Fall 15 und 17. Offensichtlich gibt es keine passenden Konstruktor von boost::thread::thread für mein Vorhaben. Aber warum nicht? Was unterscheidet meinen Code vom Codebeispiel (und Linkerprobleme gibt es hier komischerweise auch nicht??)?</p>
<p>Ich bin Neuling, was Boost angeht: Was mache ich falsch? (Und schon mal vielen Dank im Voraus :))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020358</guid><dc:creator><![CDATA[g0nz0]]></dc:creator><pubDate>Sun, 13 Feb 2011 01:16:54 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 01:35:12 GMT]]></title><description><![CDATA[<p>Hast du den C++0x Support bei deinem Compiler aktiviert? boost::thread benötigt C++0x, soweit ich weiß.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020360</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Sun, 13 Feb 2011 01:35:12 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 01:48:19 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>Hast du den C++0x Support bei deinem Compiler aktiviert? boost::thread benötigt C++0x, soweit ich weiß.</p>
</blockquote>
<p>Das stimm nicht...<br />
Außerdem gäbe das (glaub ich) eine Compiler-Fehlermeldung und keine vom Linker...</p>
<p>Du musst die Library mitlinken.</p>
<p>Dazu brauchst du in deinem Aufruf einen Verweis auf deine .a-Datei oder auf deine .dylib, wenn du dynamisch linken willst</p>
<p>Bei mir sieht der Aufruf etwa so aus:</p>
<pre><code>g++ thread.cpp -I/opt/local/include/ -o thread /opt/local/lib/libboost_thread-mt.a
</code></pre>
<p>Gruß,<br />
XSpille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020361</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020361</guid><dc:creator><![CDATA[XSpille]]></dc:creator><pubDate>Sun, 13 Feb 2011 01:48:19 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 02:04:15 GMT]]></title><description><![CDATA[<p>Ahh, okay - dass ich das aktivieren muss hat mir noch keiner gesagt.<br />
Mir schnell mal <a href="http://gcc.gnu.org/projects/cxx0x.html" rel="nofollow">das hier</a> angeguckt. Und was soll ich sagen: Es klappt nicht.<br />
&quot;man gcc&quot; ausgeführt und da sieht man dann auch warum: wird nicht unterstützt. Ich hab gcc 4.2.1, das ist zu alt. Ich werde mal versuchen, eine neuere Version zu installieren.</p>
<p>//edit<br />
@XZille: Ouh, kannst du das ein wenig ausführlicher beschreiben? Was für eine .a Datei? Ich hab noch nicht so häufig mit was anderem als der Standardbibliothek gearbeitet und bin deswegen auch mit Librarys linken etc. noch wenig vertraut.<br />
//edit2<br />
<a href="http://www.boost.org/doc/libs/" rel="nofollow">hier</a> steht bei Thread: &quot;Build &amp; Link.... Automatic linking&quot;. Was sagt mir das jetzt? Muss ich doch nichts zusätzlich linken?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020362</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020362</guid><dc:creator><![CDATA[g0nz0]]></dc:creator><pubDate>Sun, 13 Feb 2011 02:04:15 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 02:08:25 GMT]]></title><description><![CDATA[<p>g0nz0 schrieb:</p>
<blockquote>
<p>@XZille: Ouh, kannst du das ein wenig ausführlicher beschreiben? Was für eine .a Datei? Ich hab noch nicht so häufig mit was anderem als der Standardbibliothek gearbeitet und bin deswegen auch mit Librarys linken etc. noch wenig vertraut.</p>
</blockquote>
<p>Als du boost installiert hast, hat er irgendwo diese Dateien erstellt.<br />
Wo kann ich dir leider nicht sagen.<br />
(Ich kenn ja nichtmal dein OS)<br />
Ich hab die auch suchen müssen. Vermutlich in irgendeinem lib-Verzeichnnis</p>
<p>Ein Update von gcc kann sicher nicht schaden, aber wie gesagt, du brauchst kein C++0x</p>
<blockquote>
<p>My-MacBook-Pro:test Spille$ g++-4.2 thread2.cpp -I/opt/local/include/ -o thread /opt/local/lib/libboost_thread-mt.a<br />
My-MacBook-Pro:test Spille$ g++-4.2 --version<br />
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)<br />
Copyright (C) 2007 Free Software Foundation, Inc.<br />
This is free software; see the source for copying conditions. There is NO<br />
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2020363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020363</guid><dc:creator><![CDATA[XSpille]]></dc:creator><pubDate>Sun, 13 Feb 2011 02:08:25 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 03:42:20 GMT]]></title><description><![CDATA[<p>Hmm,</p>
<p>ganz egal wie ich es kompiliere...<br />
riesig inkl. pfadangabe zu libboost_thread.a:</p>
<pre><code>g++ spielesammlung.cpp -I /Library/boost_1_45_0/ -o thread.out /Library/boost_1_45_0/bin.v2/libs/thread/build/darwin-4.2.1/release/architecture-combined/link-static/threading-multi/libboost_thread.a  -lcurses
</code></pre>
<p>vergleichsweise kurz nur zum boost-Verzeichnis:</p>
<pre><code>g++ spielesammlung.cpp -I /Library/boost_1_45_0/ -lcurses
</code></pre>
<p>Es kommt immer wieder die Fehlermeldungen von oben - sowohl bei dem Beispiel als auch bei meinem Code <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020365</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020365</guid><dc:creator><![CDATA[g0nz0]]></dc:creator><pubDate>Sun, 13 Feb 2011 03:42:20 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 10:01:46 GMT]]></title><description><![CDATA[<p>1. Was für ein System hast du?<br />
2. Hast du die Boost Bibliothek gebaut?<br />
3. Wenn sie gebaut wurde, wo befinden sich die Bibliotheken? Hast du im Boost-Verzeichnis einen Unterordner <code>/stage/lib/</code> ?<br />
4. Boost-Version ist 1.45, wenn ich das richtig sehe?<br />
5. Wenn der Unterordner existiert, sich darin die Bibliotheken befinden und du die oben erwähnte Version hast, dann würde ich das hier probieren:</p>
<pre><code>g++ spielesammlung.cpp -I /Library/boost_1_45_0/ -o thread.out /Library/boost_1_45_0/stage/lib/libboost-thread-gcc42-mt-1_45.a
</code></pre>
<p>Überprüf bitte, ob dieses File ( <code>libboost-thread-gcc42-mt-1_45.a</code> ) auch existiert im Unterverzeichnis <code>/stage/lib/</code> . Es könnte auch so ähnlich heissen, ich bin mir nicht sicher, ob ich mich an alle Konventionen gehalten habe der Namensgebung <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>
<p>6. Verwende eine IDE!</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020389</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sun, 13 Feb 2011 10:01:46 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 10:15:58 GMT]]></title><description><![CDATA[<p>Auch auf dem Mac sollte Boost installiert werden. Das Installationsverzeichnis der Bibliotheken wird beim Linken mit der Compileroption -L &lt;Pfad&gt; angegeben. Die eigentlich Bibliothek wird mit -lboost_thread an den Linker übergeben. Außerdem müsste bei allen Compileschritten die Option -pthread angegeben werden, um den Compiler in den Threadmodus zu schalten. Der Aufruf sähe dann so aus:</p>
<pre><code>g++ -c spielesammlung.cpp -I&lt;Pfad zu den Boostincludes&gt; -pthread
g++ -o sielesammlung spielesammlung.o -L&lt;Pfad zu den Boost Libs&gt; -lboost_thread -pthread
</code></pre>
<p>Wenn du die Curses-Bibliothek benutzt fehlt natürlich noch das -lcurses.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020395</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sun, 13 Feb 2011 10:15:58 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 12:23:13 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9752">@Dravere</a><br />
Ich hab Mac OS X in der neuesten Version. Die Boost Bibliothek hab ich nach <a href="http://www.technoboria.com/2009/07/simple-guide-to-installing-boost-on-mac-os-x/" rel="nofollow">dieser Anleitung</a> gebaut. Die Bibliotheken sind in <code>/stage/lib/</code> , allerdings befindet sich dort nicht <code>libboost-thread-gcc42-mt-1_45.a</code> , sondern <code>libboost_thread.a</code> . Boost hab in in der neusten Version 1.45. Der Aufruf</p>
<pre><code>g++ spielesammlung.cpp -I /Library/boost_1_45_0/ /Library/boost_1_45_0/stage/lib/libboost_thread.a  -lcurses
</code></pre>
<p>bringt mich zu der gleichen Fehlermeldung wie oben.</p>
<p>@manni66<br />
Auch deinen Vorschlag hab ich ausprobiert</p>
<pre><code>g++ -c spielesammlung.cpp -I/Library/boost_1_45_0/ -L/Library/boost_1_45_0/stage/lib/ -pthread -lcurses
</code></pre>
<p>mit - mal wieder - gleichem Resultat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020441</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020441</guid><dc:creator><![CDATA[g0nz0]]></dc:creator><pubDate>Sun, 13 Feb 2011 12:23:13 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 12:53:12 GMT]]></title><description><![CDATA[<p>Ein kleiner (vielleicht unpassender) Tip für die Zukunft,<br />
da ich vermute, dass bei boost builden etwas nicht so geklappt hat wie es sollte.</p>
<p>Ich kann dir MacPorts (<a href="http://www.macports.org/" rel="nofollow">http://www.macports.org/</a>) empfehlen.<br />
Wenn du das installiert hast, dann brauchst du einfach nur</p>
<pre><code>sudo port install boost
</code></pre>
<p>eingeben und er macht alles automatisch.</p>
<p>Da kannst du viele Libraries und Applikationen mit builden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020462</guid><dc:creator><![CDATA[XSpille]]></dc:creator><pubDate>Sun, 13 Feb 2011 12:53:12 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 13:22:18 GMT]]></title><description><![CDATA[<p>g0nz0 schrieb:</p>
<blockquote>
<p>@manni66<br />
Auch deinen Vorschlag hab ich ausprobiert</p>
<pre><code>g++ -c spielesammlung.cpp -I/Library/boost_1_45_0/ -L/Library/boost_1_45_0/stage/lib/ -pthread -lcurses
</code></pre>
<p>mit - mal wieder - gleichem Resultat.</p>
</blockquote>
<p>Wenn du das genau so ausprobiert hast, kann es ja nicht funktionieren, denn es fehlt -lboost_thread.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020470</guid><dc:creator><![CDATA[Manni66]]></dc:creator><pubDate>Sun, 13 Feb 2011 13:22:18 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 13:48:25 GMT]]></title><description><![CDATA[<p>hmmm... immer noch der gleiche Fehler.</p>
<blockquote>
<p>g++ -c spielesammlung.cpp -I/Library/boost_1_45_0/ -L/Library/boost_1_45_0/stage/lib/ -pthread -lboost_thread -lcurses<br />
In file included from spielesammlung.cpp:5:<br />
pong/pong.hpp: In member function ‘void pong::play()’:<br />
pong/pong.hpp:92: error: no matching function for call to ‘boost::thread::thread(&lt;unresolved overloaded function type&gt;)’<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:215: note: candidates are: boost::thread::thread(boost::detail::thread_move_t<a href="boost::thread" rel="nofollow">boost::thread</a>)<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:201: note: boost::thread::thread(F, typename boost::disable_if&lt;boost::is_convertible&lt;T&amp;, boost::detail::thread_move_t&lt;T&gt; &gt;, boost::thread::dummy*&gt;::type) [with F = void (pong::<em>)()]<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:154: note: boost::thread::thread()<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:122: note: boost::thread::thread(boost::detail::thread_data_ptr)<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:113: note: boost::thread::thread(boost::thread&amp;)<br />
pong/pong.hpp:94: error: no matching function for call to ‘boost::thread::thread(&lt;unresolved overloaded function type&gt;)’<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:215: note: candidates are: boost::thread::thread(boost::detail::thread_move_t<a href="boost::thread" rel="nofollow">boost::thread</a>)<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:201: note: boost::thread::thread(F, typename boost::disable_if&lt;boost::is_convertible&lt;T&amp;, boost::detail::thread_move_t&lt;T&gt; &gt;, boost::thread::dummy</em>&gt;::type) [with F = void (pong::*)()]<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:154: note: boost::thread::thread()<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:122: note: boost::thread::thread(boost::detail::thread_data_ptr)<br />
/Library/boost_1_45_0/boost/thread/detail/thread.hpp:113: note: boost::thread::thread(boost::thread&amp;)</p>
</blockquote>
<p>Das scheint doch wohl auch ein Compilerfehler zu sein und keiner vom Linker oder? Nichtsdestotrotz versuch ich grad mein Glück, indem ich boost einfach noch mal mit MacPorts builde. Sehe ich das richtig, dass boost damit in <code>opt/local/</code> landet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020479</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020479</guid><dc:creator><![CDATA[g0nz0]]></dc:creator><pubDate>Sun, 13 Feb 2011 13:48:25 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 13:54:03 GMT]]></title><description><![CDATA[<p>Das ist eine Compiler-Fehlermeldung, weil eventuell ball_moves und key_event nicht findet.</p>
<p>Funktioniert denn das andere Beispiel?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020485</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020485</guid><dc:creator><![CDATA[XSpille]]></dc:creator><pubDate>Sun, 13 Feb 2011 13:54:03 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 14:38:26 GMT]]></title><description><![CDATA[<p>Nein, ebenfalls altbekannte Linker-Fehlermeldung. Mich beschleicht auch so langsam das Gefühl, dass mit dem boost build irgendetwas nicht geklappt hat. MacPorts ist gerade am werkeln und mein Macbook kann ich gleich als Herdplatte verwenden. Ich hoffe damit wird es gleich funktionieren.</p>
<p>//Edit<br />
Erfolgserlebnis! Dass ich das noch erleben darf. Das Codebeispiel kompiliert und lässt sich ausführen. Mein Programm allerdings produziert den gleichen Fehler. Das Problem ist imho das hier: ball_moves() und key_events() scheinen <code>&lt;unresolved overloaded function type&gt;</code> s zu sein. Was heißt das und wie behebe ich den Fehler?<br />
//Edit2:<br />
Jetzt blick ich gar nicht mehr durch... Folgendes im wesentlichen gleiche Codebeispiel funktioniert. Der einzige Unterschied ist, dass ball_movev() und key_events() nicht Methoden einer Klasse sondern Funktionen sind und dass die Threads in main() definiert werden.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/thread.hpp&gt;

using namespace std;

void ball_moves(){
  int a = 0;
  while(a&lt;10){
    cout &lt;&lt; a &lt;&lt; endl;
    ++a;
  }
}
void key_events(){
  int a = 10;
  while(a&lt;20){
    cout &lt;&lt; a &lt;&lt; endl;
    ++a;
  }
} 

int main(){
  boost::thread t1(ball_moves); 
  t1.join(); 
  boost::thread t2(key_events);
  t2.join();
  return 0;
}
</code></pre>
<p>Was mich zusätzlich irritiert ist die Tatsache, dass ich als Ausgabe fortlaufend die Zahlen 0 bis 19 bekomme. Ich dachte, das läuft gleichzeitig ab? Jetzt ist es doch wieder hintereinander!? Habe es noch auf die Spitze getrieben und in der ersten Funktion nach jeder Ausgabe die Wartefunktion des Beispielcodes implementiert. Resultat ist das gleiche, Ausgabe von 0 bis 19. Das heißt, die Schleifen laufen nichtmal synchron... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020486</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020486</guid><dc:creator><![CDATA[g0nz0]]></dc:creator><pubDate>Sun, 13 Feb 2011 14:38:26 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 15:44:56 GMT]]></title><description><![CDATA[<p>Du musst den ersten Thread joinen, nachdem du den zweiten gestartet hast <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 />
Edit: Außerdem würde ich die Zugriffe auf cout synchronisieren.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/thread.hpp&gt;

boost::mutex mutex;

void ball_moves()
{
    for(int a = 0; a &lt; 10; ++a)
    {
        boost::lock_guard&lt;boost::mutex&gt; guard(mutex);
        std::cout &lt;&lt; a &lt;&lt; std::endl;
    }
}

void key_events()
{
    for(int a = 10; a &lt; 20; ++a)
    {
        boost::lock_guard&lt;boost::mutex&gt; guard(mutex);
        std::cout &lt;&lt; a &lt;&lt; std::endl;
    }
}

int main()
{
   boost::thread t1(ball_moves);
   boost::thread t2(key_events);
   t1.join();
   t2.join();
}
</code></pre>
<p>Man könnte natürlich auch den lock-guard vor der Schleife erzeugen, dann würden halt alle Zahlen eines Threads nacheinander ausgegeben werden. (Weiters wäre es effizienter.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020506</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Sun, 13 Feb 2011 15:44:56 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 16:40:59 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/25374">@g0nz0</a>:<br />
Wenn du Memberfunktionen als Thread ausführen willst, dann brauchst du einen &quot;this&quot; Zeiger dazu. boost::thread kann sich den nicht aus den Fingern saugen.<br />
-&gt; boost::bind verwenden.</p>
<pre><code class="language-cpp">#include &lt;boost/bind.hpp&gt;

...

boost::thread t1(boost::bind(&amp;klassenname::ball_moves, this));
</code></pre>
<p>EDIT: hatte den boost::bind Aufruf vergessen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2020511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020511</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 13 Feb 2011 16:40:59 GMT</pubDate></item><item><title><![CDATA[Reply to boost::thread will nicht funktionieren on Sun, 13 Feb 2011 16:21:15 GMT]]></title><description><![CDATA[<p>Vielen vielen lieben Dank euch allen. Es war eine schwere Geburt, aber ENDLICH läuft alles so wie ichs will <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/2020535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2020535</guid><dc:creator><![CDATA[g0nz0]]></dc:creator><pubDate>Sun, 13 Feb 2011 16:21:15 GMT</pubDate></item></channel></rss>