2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-21 17:12:22 +00:00
Files
python/libs/python/doc/building.html
2000-12-06 19:18:05 +00:00

117 lines
4.4 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<title>
Building an Extension Module
</title>
<div>
<h1>
<img width="277" height="86" id="_x0000_i1025" align="center"
src="../../../c++boost.gif" alt= "c++boost.gif (8819 bytes)">Building an Extension Module
</h1>
<p>
Right now, the only supported configuration is one in which the BPL
source files are statically linked with the source for your extension
module. BPL comes with a standard build process that compiles the
BPL sources, builds the library <code>'libboostpython.a'</code>,
runs a comprehensive test suite and (upon success)
copies the library into an installation directory specified by the
user. To involke this build process, you need to do the following:
<h4>Compilation with GNU g++:</h4>
<blockquote><pre>
> cd &lt;boost_root&gt;/libs/python
> setenv CXX g++ # use g++
>
> ./configure \
--with-pythoninc=/usr/local/include/python1.5 \
--with-extra-includes=/usr/local/STLport
>
> make install
</pre></blockquote>
where
<blockquote><pre>
--with-pythoninc: the directory where 'Python.h' lives
--with-extra-includes: the directory where STLport includes
or the 'limits' header are
</pre></blockquote>
<h4>Compilation with another compiler:</h4>
<blockquote><pre>
> cd &lt;boost_root&gt;/libs/python
> setenv CXX CC # your compiler
>
> ./configure \
--with-pythoninc=/usr/local/include/python1.5 \
--with-shared-cxx-linker="$CXX -G" \
--with-position-independent-code-flag=-pic
>
> make install
</pre></blockquote>
where
<blockquote><pre>
--with-pythoninc: as above
--with-shared-cxx-linker: command to build a shared library from C++
object files (needed for Python modules)
--with-position-independent-code-flag: flag that tells the compiler
to create position independent code (needed for shared linking)
</pre></blockquote>
<p>
<code>configure</code> provides additional options that are listed
after invoking
<blockquote><pre>
> ./configure --help
</pre></blockquote>
Of particular interest are the following options:
<blockquote><pre>
--libdir: the install directory for 'libboostpython.a'
--enable-shared-library-extension: the file extension for shared libraries
</pre></blockquote>
For most options, configure provides reasonable defaults, given in
brackets. In particular, it is able to guess the right settings for
shared library creation and linking on some common systems. Likewise,
it tries to find Python in some standard directories if you don't
specify a path explicitly.
<p>
If this build process doesn't work for you, you must compile the
source files manually. The BPL source files are:
<blockquote>
<pre>
<a href="../../../libs/python/src/extension_class.cpp">extclass.cpp</a>
<a href="../../../libs/python/src/functions.cpp">functions.cpp</a>
<a href="../../../libs/python/src/init_function.cpp">init_function.cpp</a>
<a href="../../../libs/python/src/module_builder.cpp">module.cpp</a>
<a href="../../../libs/python/src/types.cpp">newtypes.cpp</a>
<a href="../../../libs/python/src/objects.cpp">objects.cpp</a>
<a href="../../../libs/python/src/conversions.cpp">py.cpp</a>
<a href="../../../libs/python/src/classes.cpp">subclass.cpp</a>
</pre>
</blockquote>
You may first build them into a library and link it with your
extension module source, but the effect is the same as compiling all
the source files together. Some users have successfully built the
sources into a shared library, and support for a shared library
build is planned, but not yet implemented.
<p>
Next: <a href="enums.html">Enums</a>
Previous: <a href="under-the-hood.html">A Peek Under the Hood</a>
Up: <a href="index.html">Top</a>
<p>
&copy; Copyright David Abrahams 2000. Permission to copy, use, modify,
sell and distribute this document is granted provided this copyright
notice appears in all copies. This document is provided ``as
is'' without express or implied warranty, and with no claim as to
its suitability for any purpose.
<p>
Updated: Nov 26, 2000
</div>