Skip to content

Instantly share code, notes, and snippets.

@alvesjnr
Created June 14, 2012 09:41
Show Gist options
  • Save alvesjnr/2929333 to your computer and use it in GitHub Desktop.
Save alvesjnr/2929333 to your computer and use it in GitHub Desktop.
Minimum boost+python working example
#include <Python.h>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
using namespace boost::python;
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(hello)
{
def("greet", greet);
}
#setup.py
from distutils.core import setup
from distutils.extension import Extension
import os.path
import sys
include_dirs = ["/usr/include/boost","."]
libraries=["boost_python-py27"]
library_dirs=['/usr/local/lib', "/usr/lib/python2.7"]
files = ["hello.cpp"]
setup(name="hello",
ext_modules=[
Extension("hello",files,
library_dirs=library_dirs,
libraries=libraries,
include_dirs=include_dirs,
depends=[]),
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment