Notebook
#ifndef EXTMODULE_H #define EXTMODULE_H #ifdef __cplusplus extern "C" { #endif /* Python.h must be included before everything else */ #include "Python.h" /* include system headers here */ #if !defined(EXTMODULE_IMPORT_ARRAY) #define NO_IMPORT_ARRAY #endif #include "numpy/arrayobject.h" #ifdef __cplusplus } #endif #endif
#define EXTMODULE_IMPORT_ARRAY #include "extmodule.h" #undef EXTMODULE_IMPORT_ARRAY static PyObject* FooError; static PyObject* Ext_Foo(PyObject* obj, PyObject* args) { Py_INCREF(Py_None); return Py_None; } static PyMethodDef methods[] = { {"foo", (PyCFunction) Ext_Foo, METH_VARARGS, ""}, {NULL, NULL, 0, NULL} }; PyMODINIT_FUNC init_extmodule() { PyObject* m; m = Py_InitModule("_extmodule", methods); import_array(); SVMError = PyErr_NewException("_extmodule.FooError", NULL, NULL); Py_INCREF(FooError); PyModule_AddObject(m, "FooError", FooError); }
#inlude "Python.h" #include "numpy/arrayobject.h" /* remainder of extmodule.c after here */
extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_Dealloc referenced in function _PySwigObject_format extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_NegativeRefcount referenced in function _PySwigObject_format extmodule.obj : error LNK2001: unresolved external symbol __imp___Py_RefTotal extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugFree referenced in function _PySwigObject_dealloc extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugMalloc referenced in function _PySwigObject_New extmodule.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs referenced in function _init_extmodule
#!/bin/sh valgrind \ --tool=memcheck \ --leak-check=yes \ --error-limit=no \ --suppressions=valgrind-python.supp \ --num-callers=10 \ -v \ python $1