delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/08/06/05:36:40

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Reply-To: <Peter DOT Bienstman AT rug DOT ac DOT be>
From: "Peter Bienstman" <Peter DOT Bienstman AT rug DOT ac DOT be>
To: "Jason Tishler" <jason AT tishler DOT net>, <cygwin AT sources DOT redhat DOT com>
Subject: RE: building Python extension modules - crash on import
Date: Mon, 6 Aug 2001 11:36:08 +0200
Message-ID: <000001c11e5b$38aaa810$0454c19d@intec.rug.ac.be>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0
Importance: Normal
In-Reply-To: <20010805220448.B496@dothill.com>
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

------=_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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019