Mail Archives: cygwin/2001/08/06/05:36:40
------=_NextPart_000_0001_01C11E6B.FC34FEB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
> If you can refer me to a self contained (i.e. not dependent on other
> libraries, etc.) Python C++ extension, then I'm willing to fiddle around
> with it.
Attached are a simple C++ file convert.cpp and a makefile. The Python
extension does however require the Boost Python Library (www.boost.org), a
C++ system to create Python extension modules.
The linking fails with errors like:
convert.o(.complex<double>
boost::python::detail::text$complex_from_python<double>(_object *,
boost::python::type<double>)+0x10):convert.cpp: undefined reference to
`PyInt_Type'
../
/users/pbienst/tmp/boost_cvs/libs/python/src/libboost_python.a(extension_cla
ss.o)(.text+0x3ad):extension_class.cpp: undefined reference to
`PyExc_RuntimeError'
...
These are symbols which I suppose must be in libpython2.1.
Thanks,
Peter
-------------------------------------
Peter Bienstman
Department of Information Technology
INTEC/IMEC - Ghent University
St.-Pietersnieuwstraat 41
B-9000 Gent - Belgium
E-mail: Peter DOT Bienstman AT rug DOT ac DOT be
Tel: +32 9 264 3445
Fax: +32 9 264 3593
-------------------------------------
------=_NextPart_000_0001_01C11E6B.FC34FEB0
Content-Type: application/octet-stream;
name="convert.cpp"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="convert.cpp"
#include <iostream>=0A=
#include "boost/python/class_builder.hpp"=0A=
=0A=
using namespace boost::python;=0A=
=0A=
struct Expression { Expression() {} };=0A=
=0A=
struct Term =0A=
{=0A=
Term() {}=0A=
Term(const Expression&) {}=0A=
};=0A=
=0A=
void f(const Term& t) {}=0A=
=0A=
struct A { A(const Term&) {} };=0A=
=0A=
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE=0A=
=0A=
PyObject* to_python(const Expression& e)=0A=
{=0A=
return to_python(Term(e));=0A=
}=0A=
=0A=
BOOST_PYTHON_END_CONVERSION_NAMESPACE=0A=
=0A=
BOOST_PYTHON_MODULE_INIT(convert)=0A=
{=0A=
try=0A=
{=0A=
=0A=
module_builder convert("convert");=0A=
=0A=
class_builder<Term> Term_(convert, "Term");=0A=
Term_.def(constructor<>());=0A=
Term_.def(constructor<const Expression&>());=0A=
=0A=
class_builder<Expression> Expression_(convert, "Expression");=0A=
Expression_.def(constructor<>());=0A=
=0A=
convert.def(f , "f");=0A=
=0A=
class_builder<A> A_(convert, "A");=0A=
A_.def(constructor<const Term&>());=0A=
}=0A=
catch(...)=0A=
{=0A=
} =0A=
}=0A=
=0A=
=0A=
=0A=
=0A=
------=_NextPart_000_0001_01C11E6B.FC34FEB0
Content-Type: application/octet-stream;
name="makefile"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="makefile"
# location of the Python header files=0A=
=0A=
PYTHON =3D /usr/include/python2.1=0A=
=0A=
# location of the Boost Python include files and library=0A=
=0A=
BOOST_INC =3D /users/pbienst/tmp/boost_cvs=0A=
BOOST_LIB =3D /users/pbienst/tmp/boost_cvs/libs/python/src=0A=
=0A=
convert.dll: convert.o=0A=
g++ -shared -Wl,--enable-auto-image-base,--export-dynamic \=0A=
convert.o -L$(BOOST_LIB) -lboost_python \=0A=
-L/usr/lib/python2.1/config -lpython2.1 \=0A=
-o convert.dll=0A=
=0A=
convert.o: convert.cpp=0A=
g++ -I$(PYTHON) -I$(BOOST_INC) -c convert.cpp =0A=
=0A=
clean:=0A=
rm -f *.o *.dll *.a *~ core=0A=
------=_NextPart_000_0001_01C11E6B.FC34FEB0
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------=_NextPart_000_0001_01C11E6B.FC34FEB0--
- Raw text -