Veles
Veles

Reputation: 1542

Extending Python with C++ no SWIG

OK so I have a C++ function with a header like this:

int myfunc(vector<int> a, vector<mystruct> b, vector<int> c)

I have written the wrapper code (using Python.h as I have done many times with C, which translates the Python data types into the vector datatypes and structs I use in my program). The problem is I don't know how to tell setup.py to compile it with g++, I get a bunch of errors when I run

setup.py build -i

My setup.py:

from distutils.core import setup, Extension

setup(name="MyModule", version="1.0",
  ext_modules=[Extension("MyModule", ["myfunc.cpp"])])

Can anyone tell me how I can make the build process use g++ a not gcc

Upvotes: 1

Views: 149

Answers (1)

peoro
peoro

Reputation: 26060

You should add language="c++" to your Extension object:

Extension("MyModule", ["myfunc.cpp"], language="c++")

Upvotes: 1

Related Questions