This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
RE: building Python extension modules - crash on import
- To: <Peter dot Bienstman at rug dot ac dot be>, "'Jason Tishler'" <jason at tishler dot net>
- Subject: RE: building Python extension modules - crash on import
- From: "Norman Vine" <nhv at cape dot com>
- Date: Mon, 6 Aug 2001 10:02:27 -0400
- Cc: <cygwin at cygwin dot com>
- Reply-To: <nhv at cape dot com>
Peter Bienstman writes:
>
>> 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.
Try the attached Makefiles
The second Makefile goes in
$BOOST / libs / python / build
then cd into above directory and
% make
then to make sure things are working < well almost >
% cd ../test
% python doctest.py -v
< I get 52 passed and 1 failure on above >
then try making your test program
FYI --
I have Cygwin mounted at '/'
and $BOOST at '/src/boost'
adjust Makefiles according to your system
I also am using the latest Cygwin snapshot
and a locally compiled Python 2.1
< neither probably matters >
Cheers
Norman Vine
Makefile
#include <iostream>
#include "boost/python/class_builder.hpp"
using namespace boost::python;
struct Expression { Expression() {} };
struct Term
{
Term() {}
Term(const Expression&) {}
};
void f(const Term& t) {}
struct A { A(const Term&) {} };
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
PyObject* to_python(const Expression& e)
{
return to_python(Term(e));
}
BOOST_PYTHON_END_CONVERSION_NAMESPACE
BOOST_PYTHON_MODULE_INIT(convert)
{
try
{
module_builder convert("convert");
class_builder<Term> Term_(convert, "Term");
Term_.def(constructor<>());
Term_.def(constructor<const Expression&>());
class_builder<Expression> Expression_(convert, "Expression");
Expression_.def(constructor<>());
convert.def(f , "f");
class_builder<A> A_(convert, "A");
A_.def(constructor<const Term&>());
}
catch(...)
{
}
}
Makefile
--
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/