Created
June 14, 2012 09:41
-
-
Save alvesjnr/2929333 to your computer and use it in GitHub Desktop.
Minimum boost+python working example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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