problem building C++ extension module using distutils

harold fellermann dadapapa at
Thu Feb 13 15:56:32 CET 2003


I try to build a C++ extension module for python 2.2 using distutils.
My has the following content:

from distutils.core import setup, Extension

module1 = Extension('network',

setup (name='network',
       ext_modules = [module1]

The build works fine, as long as I use only C syntax and semantics.
But trying e.g. to define a class or templates results in an error,
whenever I invoke 'python build':

running build
running build_ext
building 'network' extension
creating build
creating build/temp.linux-i686-2.2
-march=i586 -mcpu=i686 -fmessage-length=0 -fPIC -fPIC
-I/usr/include/python2.2 -c pywrapper.cpp -o
In file included from pywrapper.cpp:3:
network.h:16: parse error before '<' token

Of course. network.h declares class Network which inherits a template
... gcc won't let me compile the stuff.

So: is there any possibility (option or so) to teach setup using g++
rather than gcc for the compilation. I inserted the line
"extra_compile_args=['-xc++']" within the definition of module1, but
then the mentioned gcc call warns me:

gcc: warning: '-x c++' after last input file has no effect

and I agree to him: the result stays the same :-(

Does anyone know a possibility to teach distutils.core.setup to use
the right (c++) compiler? Any clues or suggestions are welcomed!


- harold fellermann -

More information about the Python-list mailing list