Usando Boost.Python en Debian (sin bjam)
Deberán instalar el paquete libboost-python-dev de Debian. Luego:
#include <boost/python.hpp>
using namespace boost::python;char const* greet()
{
return “hello, world”;
}BOOST_PYTHON_MODULE(hello)
{
def(”greet”, greet);
}
Para compilar:
gcc -shared -Wl,-soname,hello -I/usr/include \
`python2.4-config –includes` `python2.4-config –libs` \
-lboost_python -o hello.so hello.cpp
Para ejecutar:
$ python
Python 2.4.4 (#2, Apr 5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import hello
>>> hello.greet
<Boost.Python.function object at 0×81a1c98>
>>> hello.greet()
‘hello, world’
February 3rd, 2008 at 19:53
In python2.4-config, you should use :
python2.4-config –includes
instead of
python2.4-config -includes
Thanks for your blog post, it was very helpful for me!
February 3rd, 2008 at 20:47
Denis:
Thanks for the fix! I did test all the commands before posting’em here, but the blog engine changed the dashes!
Español:
Los parámetros del comando python2.4-config llevan doble guión, pero el WordPress los cambia a uno solo (WTF¿?)
Saludos!