<?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.Extension Tutorial 1 - Problem]]></title><description><![CDATA[<p>Hi,</p>
<p>Ich bin ein totaler Anfänger, was die Boost-Bibliotheken betrifft und wollte jetzt Boost.Extension verwenden, um ein Plugin-basiertes Programm zu schreiben.<br />
Nachdem ich mich durch die Installation der Boost-Bibliotheken gekämpft hatte, wollte ich Tutorial 1 zu Extension ausprobieren:<br />
[url]<a href="http://boost-extension.redshoelace.c" rel="nofollow">http://boost-extension.redshoelace.c</a>...als.tutorial01 [/url]</p>
<p>Also habe ich die folgenden Dateien &amp; Ordner angelegt:<br />
shared_test/<br />
..|<br />
..+- Jamroot<br />
..+- tutorial_1/<br />
.........|<br />
.........+- hello_world.cpp<br />
.........+- main.cpp</p>
<p>Jamroot sieht so aus:</p>
<pre><code>import type : change-generated-target-suffix ;
import type : change-generated-target-prefix ;
type.change-generated-target-suffix SHARED_LIB : : extension ;
type.change-generated-target-prefix SHARED_LIB : : lib ; 

import os ;

local BOOST_ROOT = [ os.environ /usr/local/include/boost ] ; 
project
    : requirements
      &lt;include&gt;#(BOOST_ROOT)
    :
    ;

lib tutorial_1 : tutorial_1/hello_world.cpp : &lt;link&gt;shared ;
exe tutorial_1_bin : tutorial_1/main.cpp ;

install binaries :
  tutorial_1 tutorial_1_bin
  ;
</code></pre>
<p>hello_world.cpp sieht so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/extension/extension.hpp&gt;

extern &quot;C&quot;

void BOOST_EXTENSION_EXPORT_DECL
boost_extension_hello_world (int repetitions)
{
    for (int i = 0; i &lt; repetitions; i++) {
        std::cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; std::endl;
    }
}
</code></pre>
<p>Und main.cpp sieht so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/extension/shared_library.hpp&gt;
#include &lt;boost/function.hpp&gt;

class shared_library;

int main()
{
    std::string library_path = &quot;libtutorial_1.extension&quot;;
    shared_library lib(library_path);
    if (!lib.open()) {
        std::cerr &lt;&lt; &quot;Library failed to open: &quot; &lt;&lt; library_path &lt;&lt; std &lt;&lt; endl;
        return 1;
    }

    boost::function&lt;void (int)&gt;
      f(lib.get&lt;void, int&gt;(&quot;boost_extension_hello_world&quot;));

    if (!f) {
        std::cerr &lt;&lt; &quot;Function not found!&quot; &lt;&lt; std::endl;
        return 1;
    }

    f(4);
}
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> Jetzt zum Problem: Wenn ich mich im &quot;shared_test&quot;-Ordner befinde und die Dateien mittels<br />
bjam<br />
zu kompilieren versuche, erhalte ich die folgenden Fehlermeldungen:</p>
<pre><code>gcc.compile.c++ bin/gcc-4.4.3/debug/tutorial_1/main.o 
tutorial_1/main.cpp: In function ‘int main()’: 
tutorial_1/main.cpp:10: error: variable ‘shared_library lib’ has initializer but incomplete type 
tutorial_1/main.cpp:12: error: expected primary-expression before ‘&lt;&lt;’ token 
tutorial_1/main.cpp:12: error: ‘endl’ was not declared in this scope 
tutorial_1/main.cpp:17: error: expected primary-expression before ‘void’ 
tutorial_1/main.cpp:17: error: expected primary-expression before ‘int’
</code></pre>
<p>Sieht hier irgendjemand das Problem? Ich bin mir sicher, dass es ein Anfängerfehler ist. <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/topic/274604/boost-extension-tutorial-1-problem</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 10:26:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/274604.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Sep 2010 11:09:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Boost.Extension Tutorial 1 - Problem on Wed, 29 Sep 2010 11:09:08 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Ich bin ein totaler Anfänger, was die Boost-Bibliotheken betrifft und wollte jetzt Boost.Extension verwenden, um ein Plugin-basiertes Programm zu schreiben.<br />
Nachdem ich mich durch die Installation der Boost-Bibliotheken gekämpft hatte, wollte ich Tutorial 1 zu Extension ausprobieren:<br />
[url]<a href="http://boost-extension.redshoelace.c" rel="nofollow">http://boost-extension.redshoelace.c</a>...als.tutorial01 [/url]</p>
<p>Also habe ich die folgenden Dateien &amp; Ordner angelegt:<br />
shared_test/<br />
..|<br />
..+- Jamroot<br />
..+- tutorial_1/<br />
.........|<br />
.........+- hello_world.cpp<br />
.........+- main.cpp</p>
<p>Jamroot sieht so aus:</p>
<pre><code>import type : change-generated-target-suffix ;
import type : change-generated-target-prefix ;
type.change-generated-target-suffix SHARED_LIB : : extension ;
type.change-generated-target-prefix SHARED_LIB : : lib ; 

import os ;

local BOOST_ROOT = [ os.environ /usr/local/include/boost ] ; 
project
    : requirements
      &lt;include&gt;#(BOOST_ROOT)
    :
    ;

lib tutorial_1 : tutorial_1/hello_world.cpp : &lt;link&gt;shared ;
exe tutorial_1_bin : tutorial_1/main.cpp ;

install binaries :
  tutorial_1 tutorial_1_bin
  ;
</code></pre>
<p>hello_world.cpp sieht so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/extension/extension.hpp&gt;

extern &quot;C&quot;

void BOOST_EXTENSION_EXPORT_DECL
boost_extension_hello_world (int repetitions)
{
    for (int i = 0; i &lt; repetitions; i++) {
        std::cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; std::endl;
    }
}
</code></pre>
<p>Und main.cpp sieht so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/extension/shared_library.hpp&gt;
#include &lt;boost/function.hpp&gt;

class shared_library;

int main()
{
    std::string library_path = &quot;libtutorial_1.extension&quot;;
    shared_library lib(library_path);
    if (!lib.open()) {
        std::cerr &lt;&lt; &quot;Library failed to open: &quot; &lt;&lt; library_path &lt;&lt; std &lt;&lt; endl;
        return 1;
    }

    boost::function&lt;void (int)&gt;
      f(lib.get&lt;void, int&gt;(&quot;boost_extension_hello_world&quot;));

    if (!f) {
        std::cerr &lt;&lt; &quot;Function not found!&quot; &lt;&lt; std::endl;
        return 1;
    }

    f(4);
}
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> Jetzt zum Problem: Wenn ich mich im &quot;shared_test&quot;-Ordner befinde und die Dateien mittels<br />
bjam<br />
zu kompilieren versuche, erhalte ich die folgenden Fehlermeldungen:</p>
<pre><code>gcc.compile.c++ bin/gcc-4.4.3/debug/tutorial_1/main.o 
tutorial_1/main.cpp: In function ‘int main()’: 
tutorial_1/main.cpp:10: error: variable ‘shared_library lib’ has initializer but incomplete type 
tutorial_1/main.cpp:12: error: expected primary-expression before ‘&lt;&lt;’ token 
tutorial_1/main.cpp:12: error: ‘endl’ was not declared in this scope 
tutorial_1/main.cpp:17: error: expected primary-expression before ‘void’ 
tutorial_1/main.cpp:17: error: expected primary-expression before ‘int’
</code></pre>
<p>Sieht hier irgendjemand das Problem? Ich bin mir sicher, dass es ein Anfängerfehler ist. <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/1958902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1958902</guid><dc:creator><![CDATA[aloifolia]]></dc:creator><pubDate>Wed, 29 Sep 2010 11:09:08 GMT</pubDate></item><item><title><![CDATA[Reply to Boost.Extension Tutorial 1 - Problem on Wed, 29 Sep 2010 11:20:04 GMT]]></title><description><![CDATA[<p>Die erste Fehlermeldung sagt aus, dass Du ein Objekt vom Typ shared_library erstellen möchtest, obwohl shared_library unvollständig ist. Das ist auch klar, da Du sie nur forward deklarierst (über main).</p>
<p>Du meintest vermutlich die in boost/extension/shared_library.hpp mit Sicherheit vollständig definierte Klasse boost::extensions::shared_library?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1958904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1958904</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 29 Sep 2010 11:20:04 GMT</pubDate></item><item><title><![CDATA[Reply to Boost.Extension Tutorial 1 - Problem on Wed, 29 Sep 2010 11:57:46 GMT]]></title><description><![CDATA[<p>Genau diese meinte ich :). Weißt du denn, was ich am Code ändern muss, damit es funktioniert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1958932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1958932</guid><dc:creator><![CDATA[aloifolia]]></dc:creator><pubDate>Wed, 29 Sep 2010 11:57:46 GMT</pubDate></item><item><title><![CDATA[Reply to Boost.Extension Tutorial 1 - Problem on Wed, 29 Sep 2010 12:24:48 GMT]]></title><description><![CDATA[<p>Also den Fehler für die genannten Fehlermeldungen habe ich mittels Entfernung der Vorwärtsdeklaration und Benutzung des passenden Namespaces gelöst (vielen Dank für die Hilfe!), sodass main.cpp jetzt so aussieht:</p>
<pre><code class="language-cpp">[code]#include &lt;iostream&gt;
#include &lt;boost/extension/shared_library.hpp&gt;
#include &lt;boost/function.hpp&gt;
[b]using namespace boost::extensions;[/b]

int main()
{
    std::string library_path = &quot;libtutorial_1.extension&quot;;
    shared_library::shared_library lib(library_path);
    //...
    // &quot;std &lt;&lt; endl&quot; war ebenfalls fehlerhaft
        std::cerr &lt;&lt; &quot;Library failed to open: &quot; &lt;&lt; library_path &lt;&lt; [b]std::endl[/b];
    //...
}[/code]
</code></pre>
<p>Jetzt kommen aber viel kryptischere Fehlermeldungen:<br />
gcc.compile.c++ bin/gcc-4.4.3/debug/tutorial_1/main.o<br />
gcc.link bin/gcc-4.4.3/debug/tutorial_1_bin<br />
bin/gcc-4.4.3/debug/tutorial_1/main.o: In function <code>boost::extensions::impl::load\_shared_library(char const*)': /usr/local/include/boost/extension/impl/library_impl.hpp:60: undefined reference to</code>dlopen'<br />
bin/gcc-4.4.3/debug/tutorial_1/main.o: In function <code>boost::extensions::impl::get\_function(void*, char const*)': /usr/local/include/boost/extension/impl/library_impl.hpp:64: undefined reference to</code>dlsym'<br />
bin/gcc-4.4.3/debug/tutorial_1/main.o: In function <code>boost::extensions::impl::close\_shared_library(void*)': /usr/local/include/boost/extension/impl/library_impl.hpp:67: undefined reference to</code>dlclose'</p>
<p>Könnte der Grund hierfür in einem fehlerhaften Jamfile liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1958946</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1958946</guid><dc:creator><![CDATA[aloifolia]]></dc:creator><pubDate>Wed, 29 Sep 2010 12:24:48 GMT</pubDate></item><item><title><![CDATA[Reply to Boost.Extension Tutorial 1 - Problem on Wed, 29 Sep 2010 12:57:11 GMT]]></title><description><![CDATA[<p>Das sind jetzt Linkerfehler. Boost.Extension findet die Funktionen zum Öffnen von shared libraries nicht. Abhilfe würde hier -ldl beim Linken bringen.</p>
<p>Wie (und ob) man das ganze beim Linken der Boost.Extension-Bibliothek (Jamfile) selbst lösen kann, wüsste ich jetzt nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1958988</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1958988</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Wed, 29 Sep 2010 12:57:11 GMT</pubDate></item><item><title><![CDATA[Reply to Boost.Extension Tutorial 1 - Problem on Wed, 29 Sep 2010 13:25:16 GMT]]></title><description><![CDATA[<p>Ah, verstehe, dann werden also die dl-Bibliotheken nicht richtig gelinkt. Dann bleibt nur noch die Frage, wie ich das mit meiner bisherigen Methode behoben bekomme. Ich werde es mal ohne Jamfile ausprobieren und schauen, was passiert. Längerfristig werde ich aber wohl wieder auf Bjam zurückgreifen, um das Projekt einfach organisieren zu können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1959014</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1959014</guid><dc:creator><![CDATA[aloifolia]]></dc:creator><pubDate>Wed, 29 Sep 2010 13:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to Boost.Extension Tutorial 1 - Problem on Wed, 29 Sep 2010 15:55:05 GMT]]></title><description><![CDATA[<p>So, ich habe jetzt mal alles per Hand kompilieren lassen. Und zwar mit Hilfe folgender Befehle.</p>
<p>Für die dynamische Bibliothek hello_world.cpp:</p>
<pre><code>sudo g++ -shared -fPIC hello_world.cpp -o libhello.so
</code></pre>
<p>Dann das eigentliche Programm:</p>
<pre><code>sudo g++ -o hello main.cpp -ldl
</code></pre>
<p>Wenn ich das nun ausführe, wird leider nicht die dynamische Bibliothek geladen. Wie ich es in main.cpp gefordert habe, wird dies signalisiert:</p>
<pre><code>Library failed to open: libhello.so
</code></pre>
<p>Kann der Fehler nun noch an einer der beiden Quelldateien liegen, wenn das Kompilieren selber funktioniert hat? Oder kann es durch fehlerhafte Compilerparameter verursacht sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1959107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1959107</guid><dc:creator><![CDATA[aloifolia]]></dc:creator><pubDate>Wed, 29 Sep 2010 15:55:05 GMT</pubDate></item></channel></rss>