<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Correction: the 2 output files are hello.o and hello_ext.lib<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Messaggio originale -----<br>Da: k k &lt;ralvek@yahoo.it&gt;<br>A: c++-sig@python.org<br>Inviato: Martedì 30 settembre 2008, 14:17:56<br>Oggetto: Building "hello world" with Boost.Python<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Hi all,<br>i want to use a C++ dll (containing overloaded functions) with Python.<br>I'm trying to use Boost.Python.<br>I dowloaded it and now I'm doing the hello world tutorial situated in the boost installation folder in \libs\python\example\tutorial<br>I got also bjam and configured it
 to work with gcc and python 2.5.<br>This is the hello.cpp file to export:<br><br><span style="font-weight: bold;">#include &lt;boost/python/module.hpp&gt;</span><br style="font-weight: bold;"><span style="font-weight: bold;">#include &lt;boost/python/def.hpp&gt;</span><br style="font-weight: bold;"><br style="font-weight: bold;"><span style="font-weight: bold;">char const* greet()</span><br style="font-weight: bold;"><span style="font-weight: bold;">{</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp; return "hello, world";</span><br style="font-weight: bold;"><span style="font-weight: bold;">}</span><br style="font-weight: bold;"><br style="font-weight: bold;"><span style="font-weight: bold;">BOOST_PYTHON_MODULE(hello_ext)</span><br style="font-weight: bold;"><span style="font-weight: bold;">{</span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; using namespace boost::python;</span><br
 style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; def("greet", greet);</span><br style="font-weight: bold;"><span style="font-weight: bold;">}</span><br><br>I use this Jamroot file (that is in the same folder as hello.cpp):<br><br><span style="font-weight: bold;"># Copyright David Abrahams 2006. Distributed under the Boost</span><span style="font-family: monospace; font-weight: bold;"><br></span><span style="font-weight: bold;"># Software License, Version 1.0. (See
 accompanying</span><span style="font-family: monospace; font-weight: bold;"><br></span><span style="font-weight: bold;"># file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;"># Specify the path to the Boost project.&nbsp; If you move this project</span><br style="font-weight: bold;"><span style="font-weight: bold;"># adjust this path to refer to the Boost root directory.</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;">use-project boost</span><span style="font-family: monospace; font-weight: bold;"></span><br style="font-weight: bold;"><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; : ../../../.. ;</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;"># Set up the project-wide requirements that everything
 uses the</span><span style="font-family: monospace; font-weight: bold;"><br></span><span style="font-weight: bold;"># boost_python library from the project whose global ID is</span><span style="font-family: monospace; font-weight: bold;"><br></span><span style="font-weight: bold;"># /boost/python.</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;">project</span><span style="font-family: monospace; font-weight: bold;"><br>&nbsp;</span><span style="font-weight: bold;">: requirements &lt;library&gt;/boost/python//boost_python ;</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;"># Declare the three extension modules.&nbsp; You can specify multiple</span><span style="font-family: monospace; font-weight: bold;"><br></span><span style="font-weight: bold;"># source files after the colon separated by spaces.</span><span style="font-family:
 monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;">python-extension hello_ext : hello.cpp ;</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;"># A little "rule" (function) to clean up the syntax of declaring tests</span><br style="font-weight: bold;"><span style="font-weight: bold;"># of these extension modules.</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;">local rule run-test ( test-name : sources + )</span><span style="font-family: monospace; font-weight: bold;"><br>&nbsp;&nbsp;&nbsp; </span><span style="font-weight: bold;">{</span><span style="font-family: monospace; font-weight: bold;"><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span style="font-weight: bold;">import testing ;</span><span style="font-family: monospace; font-weight: bold;"><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; </span><span
 style="font-weight: bold;">testing.make-test run-pyd : $(sources) : : $(test-name) ;</span><span style="font-family: monospace; font-weight: bold;"><br>&nbsp;&nbsp;&nbsp; </span><span style="font-weight: bold;">}</span><span style="font-family: monospace; font-weight: bold;"><br><br></span><span style="font-weight: bold;"># Declare test targets</span><code><br style="font-weight: bold;"><br style="font-weight: bold;"><font style="font-weight: bold;" size="3">run-test hello : hello_ext hello.py ;<br><br></font></code>In the Jamroot file i changed only this:<br><dl style="font-weight: bold;" class="codebox"><dd><code>use-project boost<br>&nbsp; : ../../../.. ;</code></dd></dl>with this(the boost root folder on on my disk):<br><br style="font-weight: bold;"><dl style="font-weight: bold;" class="codebox"><dd><code>use-project boost<br>&nbsp; : C:/boost/boost_1_35_0 ;</code></dd></dl>When i run bjam it seams that it builds well, only with some warning, but
 without any error.<br>In the tutorial they say that if all is well i should now have built the DLLs.<br>But the only things in there are 2 files: hello.o and hello.lib<br>I can't use these as python modules, how can i get the DLL? and the .pyd?<br><br>Thanks in advance.<br>Stefano<br><br><br><br></div></div><br>__________________________________________________<br>Do You Yahoo!?<br>Poco spazio e tanto spam? Yahoo! Mail ti protegge dallo spam e ti da tanto spazio gratuito per i tuoi file e i messaggi <br>http://mail.yahoo.it </div></div></div><br>



      <hr size=1><font face="Arial" size="2">Scopri il <a href="http://us.rd.yahoo.com/mail/it/taglines/yahoo/ymail/SIG=11djrg460/**http%3A%2F%2Fwww.ymailblogit.com%2Fblog%2F"> Blog di Yahoo! Mail</a>: trucchi, novità, consigli... e anche la tua opinione!</font></body></html>