<?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[Linkerfehler - Boost&#x2F;Linux]]></title><description><![CDATA[<p>Hallo allseits,</p>
<p>ich habe ein ganz merkwürdiges Problem mit Boost unter Linux (Ubuntu 14.04) - ich bekomme eine Reihe von Linkerfehlern obwohl ich die Libraries beim compilen mitangegeben habe und Boost korrekt installiert ist. Hat jemand einen Tip für mich, was ich falsch mache?</p>
<p>Das Programm kompiliert ohne Fehler oder Warnungen, daher liegt es glaube ich nicht am Source Code. Ich kompiliere mit:</p>
<pre><code>g++ -lboost_thread -lboost_system dev.cpp main.cpp
</code></pre>
<p>Die Ausgabe davon ist länger, siehe ganz unten im Post.<br />
Das komische ist, dass er sich über Libraries beschwert, die ich explizit beim compilen angegeben habe (&quot;undefined reference to boost::system::[...]&quot; trotz -lboost_system). Ich dachte also, vielleicht ist Boost nicht richtig installiert, aber ein</p>
<pre><code>sudo apt-get install libboost-all-dev
</code></pre>
<p>gibt mir</p>
<pre><code>libboost-all-dev is already the newest version.
</code></pre>
<p>Außerdem beschwert sich der Linker nicht, dass er z.b. libboost_system nicht finden kann.</p>
<p>Die g++-Version ist 4.8.2. Das Programm ist zu Testzwecken schon recht minimal, ich habe nur einen Thread, in dem ein Zeitstempel erstellt wird, und ein boost::tuple&lt;&gt;; dies gekapselt in einer Klasse (dev.cpp), die einmal instanziert wird (main.cpp). Ich kann den Source Code auch posten.<br />
Der komplette Output des Linkers:</p>
<pre><code>~/dev/boostest$ g++ -lboost_thread -lboost_system dev.cpp main.cpp
/tmp/ccfodwgK.o: In function `__static_initialization_and_destruction_0(int, int)':
dev.cpp:(.text+0x275): undefined reference to `boost::system::generic_category()'
dev.cpp:(.text+0x281): undefined reference to `boost::system::generic_category()'
dev.cpp:(.text+0x28d): undefined reference to `boost::system::system_category()'
/tmp/ccfodwgK.o: In function `boost::thread_exception::thread_exception(int, char const*)':
dev.cpp:(.text._ZN5boost16thread_exceptionC2EiPKc[_ZN5boost16thread_exceptionC5EiPKc]+0x14): undefined reference to `boost::system::system_category()'
/tmp/ccfodwgK.o: In function `boost::detail::thread_data_base::thread_data_base()':
dev.cpp:(.text._ZN5boost6detail16thread_data_baseC2Ev[_ZN5boost6detail16thread_data_baseC5Ev]+0x24): undefined reference to `vtable for boost::detail::thread_data_base'
/tmp/ccfodwgK.o: In function `boost::this_thread::sleep(boost::posix_time::ptime const&amp;)':
dev.cpp:(.text._ZN5boost11this_thread5sleepERKNS_10posix_time5ptimeE[_ZN5boost11this_thread5sleepERKNS_10posix_time5ptimeE]+0x28): undefined reference to `boost::this_thread::hiden::sleep_until(timespec const&amp;)'
/tmp/ccfodwgK.o: In function `boost::thread::start_thread()':
dev.cpp:(.text._ZN5boost6thread12start_threadEv[_ZN5boost6thread12start_threadEv]+0x15): undefined reference to `boost::thread::start_thread_noexcept()'
/tmp/ccfodwgK.o: In function `boost::thread::~thread()':
dev.cpp:(.text._ZN5boost6threadD2Ev[_ZN5boost6threadD5Ev]+0x15): undefined reference to `boost::thread::detach()'
/tmp/ccfodwgK.o: In function `boost::thread::get_id() const':
dev.cpp:(.text._ZNK5boost6thread6get_idEv[_ZNK5boost6thread6get_idEv]+0x18): undefined reference to `boost::thread::native_handle()'
/tmp/ccfodwgK.o: In function `boost::thread::join()':
dev.cpp:(.text._ZN5boost6thread4joinEv[_ZN5boost6thread4joinEv]+0x6d): undefined reference to `boost::thread::join_noexcept()'
/tmp/ccfodwgK.o: In function `boost::detail::thread_data&lt;boost::_bi::bind_t&lt;void, boost::_mfi::mf0&lt;void, mynamespace::Boostest&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;mynamespace::Boostest*&gt; &gt; &gt; &gt;::~thread_data()':
dev.cpp:(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEED2Ev[_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEED5Ev]+0x1f): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/tmp/ccfodwgK.o:(.rodata._ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEEE[_ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEEE]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base'
/tmp/ccioMWId.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0xc5): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0xd1): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0xdd): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
</code></pre>
<p>Danke!</p>
<p>PS: Der Source Code:</p>
<p>dev.h</p>
<pre><code>#ifndef DEV_H_
#define DEV_H_

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;

#include &lt;boost/thread.hpp&gt;
#include &lt;boost/date_time/posix_time/posix_time.hpp&gt;
#include &lt;boost/tuple/tuple.hpp&gt;

using namespace boost;

namespace mynamespace
{
    class Boostest
    {
        public:
			Boostest();
            ~Boostest();            
            void Sending_thread();
            void run();
    };
 }

#endif
</code></pre>
<p>dev.cpp</p>
<pre><code>#include &quot;dev.h&quot;

namespace mynamespace
{
    Boostest::Boostest() {}
    Boostest::~Boostest() {}

	void Boostest::Sending_thread()
	{
		for (int i = 0; i &lt; 255; i++)
		{
			boost::this_thread::sleep(boost::posix_time::milliseconds(40));
		}
	}

    void Boostest::run() 
    {
        thread sending_thread(boost::bind(&amp;Boostest::Sending_thread, this));
        sending_thread.join();
	}
}
</code></pre>
<p>main.cpp</p>
<pre><code>#include &quot;dev.h&quot;

using namespace mynamespace;

int main(int argc, char** argv)
{
	Boostest bt;
	bt.run();

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/330100/linkerfehler-boost-linux</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 12:57:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/330100.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Dec 2014 09:02:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Linkerfehler - Boost&#x2F;Linux on Mon, 22 Dec 2014 09:13:27 GMT]]></title><description><![CDATA[<p>Hallo allseits,</p>
<p>ich habe ein ganz merkwürdiges Problem mit Boost unter Linux (Ubuntu 14.04) - ich bekomme eine Reihe von Linkerfehlern obwohl ich die Libraries beim compilen mitangegeben habe und Boost korrekt installiert ist. Hat jemand einen Tip für mich, was ich falsch mache?</p>
<p>Das Programm kompiliert ohne Fehler oder Warnungen, daher liegt es glaube ich nicht am Source Code. Ich kompiliere mit:</p>
<pre><code>g++ -lboost_thread -lboost_system dev.cpp main.cpp
</code></pre>
<p>Die Ausgabe davon ist länger, siehe ganz unten im Post.<br />
Das komische ist, dass er sich über Libraries beschwert, die ich explizit beim compilen angegeben habe (&quot;undefined reference to boost::system::[...]&quot; trotz -lboost_system). Ich dachte also, vielleicht ist Boost nicht richtig installiert, aber ein</p>
<pre><code>sudo apt-get install libboost-all-dev
</code></pre>
<p>gibt mir</p>
<pre><code>libboost-all-dev is already the newest version.
</code></pre>
<p>Außerdem beschwert sich der Linker nicht, dass er z.b. libboost_system nicht finden kann.</p>
<p>Die g++-Version ist 4.8.2. Das Programm ist zu Testzwecken schon recht minimal, ich habe nur einen Thread, in dem ein Zeitstempel erstellt wird, und ein boost::tuple&lt;&gt;; dies gekapselt in einer Klasse (dev.cpp), die einmal instanziert wird (main.cpp). Ich kann den Source Code auch posten.<br />
Der komplette Output des Linkers:</p>
<pre><code>~/dev/boostest$ g++ -lboost_thread -lboost_system dev.cpp main.cpp
/tmp/ccfodwgK.o: In function `__static_initialization_and_destruction_0(int, int)':
dev.cpp:(.text+0x275): undefined reference to `boost::system::generic_category()'
dev.cpp:(.text+0x281): undefined reference to `boost::system::generic_category()'
dev.cpp:(.text+0x28d): undefined reference to `boost::system::system_category()'
/tmp/ccfodwgK.o: In function `boost::thread_exception::thread_exception(int, char const*)':
dev.cpp:(.text._ZN5boost16thread_exceptionC2EiPKc[_ZN5boost16thread_exceptionC5EiPKc]+0x14): undefined reference to `boost::system::system_category()'
/tmp/ccfodwgK.o: In function `boost::detail::thread_data_base::thread_data_base()':
dev.cpp:(.text._ZN5boost6detail16thread_data_baseC2Ev[_ZN5boost6detail16thread_data_baseC5Ev]+0x24): undefined reference to `vtable for boost::detail::thread_data_base'
/tmp/ccfodwgK.o: In function `boost::this_thread::sleep(boost::posix_time::ptime const&amp;)':
dev.cpp:(.text._ZN5boost11this_thread5sleepERKNS_10posix_time5ptimeE[_ZN5boost11this_thread5sleepERKNS_10posix_time5ptimeE]+0x28): undefined reference to `boost::this_thread::hiden::sleep_until(timespec const&amp;)'
/tmp/ccfodwgK.o: In function `boost::thread::start_thread()':
dev.cpp:(.text._ZN5boost6thread12start_threadEv[_ZN5boost6thread12start_threadEv]+0x15): undefined reference to `boost::thread::start_thread_noexcept()'
/tmp/ccfodwgK.o: In function `boost::thread::~thread()':
dev.cpp:(.text._ZN5boost6threadD2Ev[_ZN5boost6threadD5Ev]+0x15): undefined reference to `boost::thread::detach()'
/tmp/ccfodwgK.o: In function `boost::thread::get_id() const':
dev.cpp:(.text._ZNK5boost6thread6get_idEv[_ZNK5boost6thread6get_idEv]+0x18): undefined reference to `boost::thread::native_handle()'
/tmp/ccfodwgK.o: In function `boost::thread::join()':
dev.cpp:(.text._ZN5boost6thread4joinEv[_ZN5boost6thread4joinEv]+0x6d): undefined reference to `boost::thread::join_noexcept()'
/tmp/ccfodwgK.o: In function `boost::detail::thread_data&lt;boost::_bi::bind_t&lt;void, boost::_mfi::mf0&lt;void, mynamespace::Boostest&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;mynamespace::Boostest*&gt; &gt; &gt; &gt;::~thread_data()':
dev.cpp:(.text._ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEED2Ev[_ZN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEED5Ev]+0x1f): undefined reference to `boost::detail::thread_data_base::~thread_data_base()'
/tmp/ccfodwgK.o:(.rodata._ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEEE[_ZTIN5boost6detail11thread_dataINS_3_bi6bind_tIvNS_4_mfi3mf0IvN11mynamespace8BoostestEEENS2_5list1INS2_5valueIPS7_EEEEEEEE]+0x10): undefined reference to `typeinfo for boost::detail::thread_data_base'
/tmp/ccioMWId.o: In function `__static_initialization_and_destruction_0(int, int)':
main.cpp:(.text+0xc5): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0xd1): undefined reference to `boost::system::generic_category()'
main.cpp:(.text+0xdd): undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
</code></pre>
<p>Danke!</p>
<p>PS: Der Source Code:</p>
<p>dev.h</p>
<pre><code>#ifndef DEV_H_
#define DEV_H_

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string&gt;

#include &lt;boost/thread.hpp&gt;
#include &lt;boost/date_time/posix_time/posix_time.hpp&gt;
#include &lt;boost/tuple/tuple.hpp&gt;

using namespace boost;

namespace mynamespace
{
    class Boostest
    {
        public:
			Boostest();
            ~Boostest();            
            void Sending_thread();
            void run();
    };
 }

#endif
</code></pre>
<p>dev.cpp</p>
<pre><code>#include &quot;dev.h&quot;

namespace mynamespace
{
    Boostest::Boostest() {}
    Boostest::~Boostest() {}

	void Boostest::Sending_thread()
	{
		for (int i = 0; i &lt; 255; i++)
		{
			boost::this_thread::sleep(boost::posix_time::milliseconds(40));
		}
	}

    void Boostest::run() 
    {
        thread sending_thread(boost::bind(&amp;Boostest::Sending_thread, this));
        sending_thread.join();
	}
}
</code></pre>
<p>main.cpp</p>
<pre><code>#include &quot;dev.h&quot;

using namespace mynamespace;

int main(int argc, char** argv)
{
	Boostest bt;
	bt.run();

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2434140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2434140</guid><dc:creator><![CDATA[der_gert]]></dc:creator><pubDate>Mon, 22 Dec 2014 09:13:27 GMT</pubDate></item><item><title><![CDATA[Reply to Linkerfehler - Boost&#x2F;Linux on Mon, 22 Dec 2014 10:18:56 GMT]]></title><description><![CDATA[<p>Statische Bibliotheken? Dann müssen sie in der Kommandozeile hinter den cpp stehen.</p>
<p>32/64 Bit Mischmasch? Korrekte Version installieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2434153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2434153</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 22 Dec 2014 10:18:56 GMT</pubDate></item><item><title><![CDATA[Reply to Linkerfehler - Boost&#x2F;Linux on Mon, 22 Dec 2014 10:43:10 GMT]]></title><description><![CDATA[<p>Sind eigentlich alles dynamische Libs, soweit ich weiß. An 32/64 bit habe ich auch schon gedacht, halte ich aber für unwahrscheinlich, da ich einfach libboost-all-dev auf meinem 64-bit-Xubuntu installiert habe - sonst nichts.</p>
<p>Ich habe jetzt den Buildprozess in Compilen und Linken aufgeteilt, d.h. g++ -c für das Compilen und ld für das Linken. Um die Linker-Commandline zu bekommen, habe ich g++ -v verwendet. Und siehe da - <strong>wenn ich den --as-needed - Parameter bei ld weglasse, funktioniert es ohne Probleme</strong>!</p>
<p>Jetzt frage ich mich nur noch, was genau dieser Parameter eigentlich macht bzw. warum ihn g++ verwenden möchte. Aber immerhin funktioniert es erst mal - ich muss allerdings noch testen, ob das gelinkte Programm tatsächlich einwandfrei läuft. Wenn jemand was dazu weiß - bitte gerne melden <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="🙂"
    /> Ansonsten les' ich mal manpages... :p</p>
<p><em>Edit</em>: ok, --as-needed verhindert das Linken gegen nicht benutzte Libraries, d.h., auch wenn sie angegeben werden, werden sie nicht gelinkt - was ziemlich genau mein Problem war und auch erklärt, warum g++ die Option verwenden möchte, weil das ja eigentlich eine gute Sache ist, wenn es funktioniert. Nur warum glaubt der Linker (bzw. g++), dass ich die Boost-Libraries eigentlich nicht brauche??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2434157</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2434157</guid><dc:creator><![CDATA[der_gert]]></dc:creator><pubDate>Mon, 22 Dec 2014 10:43:10 GMT</pubDate></item><item><title><![CDATA[Reply to Linkerfehler - Boost&#x2F;Linux on Mon, 22 Dec 2014 10:52:32 GMT]]></title><description><![CDATA[<p>Dann probier auch in diesem Fall, die Libs in drr Kommandozeile nach hinten zu schieben. Der Linker bindet auch hier nur Symbole ein, die undefiniert sind. Ohne .cpp oder .o gibt es aber nichts undefiniertes.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2434159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2434159</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 22 Dec 2014 10:52:32 GMT</pubDate></item><item><title><![CDATA[Reply to Linkerfehler - Boost&#x2F;Linux on Mon, 22 Dec 2014 11:41:01 GMT]]></title><description><![CDATA[<p>Tatsächlich, das war's <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="🙂"
    /> Wieder was gelernt. Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2434164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2434164</guid><dc:creator><![CDATA[der_gert]]></dc:creator><pubDate>Mon, 22 Dec 2014 11:41:01 GMT</pubDate></item></channel></rss>