平台:ubuntu 8.10 AMD64 + Python 2.5 + Boost
创建hello.cpp文件:
在命令行模式中:
$ g++ -O3 hello.cpp -shared -o hello.so -I /usr/include/python2.5 -lboost_python -fPIC
生成hello.so
$ python
>>> import sys
>>> sys.path.append("/path/to/.so/file")
>>> import hello
>>> print hello.greet()
hello, world