??????python???д????????????????????????????????python?????????????python???????? ???????????£?????????????????????????????????£???????????????
????????? ????????в??????CentOS6.5_x64??python?汾?2.6
??????????????
????1????д??鶯?????????
???????????????????
????????callTest1.cpp?????£?
????extern "C"
????{
????int Max(int i1??int i2)
????{
????return (i1>i2)?i1:i2;
????}
????}
??????bash?????????????
????g++ -fPIC -shared -o libcallTest1.so callTest1.cpp
???????????????libcallTest1.so
????2?????python????????
???????????ctypes????????????????????£?
????#! /usr/bin/env python
????from ctypes import *
????import os
????so1 = CDLL(os.getcwd() + '/libcallTest1.so')
????print so1.Max(1??3)
???????boost?????python
?????????????????????python??飬???import???????????ɡ? ????????????????????boost???????????????????????????????????
????boost??????http://www.boost.org/
????1???????????£?
???????????boostCallTest1.cpp
????????????
????int Max(int i1??int i2)
????{
????return (i1>i2)?i1:i2;
????}
????#include <boost/python/module.hpp>
????#include <boost/python/def.hpp>
????using namespace boost::python;
????BOOST_PYTHON_MODULE(boostCallTest1)
????{
????def("Max"??Max);
????}
????2????д????????
??????????? setup.py
????????????
????#!/usr/bin/env python
????from distutils.core import setup
????from distutils.extension import Extension
????setup(name="PackageName"??
????ext_modules=[
????Extension("boostCallTest1"?? ["boostCallTest1.cpp"]??
????libraries = ["boost_python"])
????])