building Python extension modules - crash on import

Peter Bienstman Peter.Bienstman@rug.ac.be
Mon Aug 6 02:36:00 GMT 2001


> 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.Bienstman@rug.ac.be
Tel: +32 9 264 3445
Fax: +32 9 264 3593
-------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: convert.cpp
Type: text/x-c
Size: 862 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20010806/3fa680f4/attachment.bin>
-------------- next part --------------
# location of the Python header files

PYTHON = /usr/include/python2.1

# location of the Boost Python include files and library

BOOST_INC = /users/pbienst/tmp/boost_cvs
BOOST_LIB = /users/pbienst/tmp/boost_cvs/libs/python/src

convert.dll: convert.o
	g++ -shared -Wl,--enable-auto-image-base,--export-dynamic \
	convert.o -L$(BOOST_LIB) -lboost_python \
	-L/usr/lib/python2.1/config -lpython2.1 \
	-o convert.dll

convert.o: convert.cpp
	g++ -I$(PYTHON) -I$(BOOST_INC) -c convert.cpp 

clean:
	rm -f *.o *.dll *.a *~ core



More information about the Cygwin mailing list