python extend c++ module

§ä´M¦Û¤vªº¤@¤ù¤Ñ command.bbs at
Mon Jun 29 13:13:00 CEST 2009

I have written a c++ extend module and I use distutils to build.
from distutils.core import setup, Extension

setup(name="noddy", version="1.0",
         Extension("noddy3", ["noddy3.cpp", "a.cpp"])

I found it's quite strange when compiling. I didn't use extern "C" at all
, how can python get the right c++ funciton name without any compile error??

I found that it first use gcc to compile noddy3.cpp and then link by g++.

Could anyone explain what it's all about?

Thanks a lot!!

here is the compiling message.
running install

running build

running build_ext

building 'noddy3' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall
-Wstrict-prototypes -fPIC -I/usr/local/include/python2.6 -c noddy3.cpp -o

cc1plus: warning: command line option "-Wstrict-prototypes" is valid for
Ada/C/ObjC but not for C++
g++ -pthread -shared build/temp.linux-i686-2.6/noddy3.o
build/temp.linux-i686-2.6/a.o -o build/lib.linux-i686-2.6/
running install_lib

copying build/lib.linux-i686-2.6/ ->

running install_egg_info

Removing /usr/local/lib/python2.6/site-packages/noddy-1.0-py2.6.egg-info

Writing /usr/local/lib/python2.6/site-packages/noddy-1.0-py2.6.egg-info

※Post by command       from 59-124-255-226.HINET-IP.

More information about the Python-list mailing list