Wrapper function

Java and Swing codecraig at gmail.com
Tue Oct 11 14:00:25 EDT 2005


Diez, yes you were right!  But I have other problems now.

I now have...

#include <stdlib.h>
#include <string.h>
#include "Python.h"

int doStuff(const char *input, const char *d) {...}

static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
        int result;
        char *input = 0;
        char *d = 0;
        int ok = PyArg_ParseTuple(args, "ss", &input, &d);
        if (!ok) return 0;

        result = doStuff(input, d);

        return PyBuildValue("i", result);
}

static PyMethodDef myMethods[] =
{
	{"PyDoStuff", wrap_doStuff, METH_VARARGS, "some documentation"},
	{NULL, NULL}
};

extern PyMODINIT_FUNC initMyDLL(void)
{
    Py_InitModule4(
        "MyDLL", myMethods, "my doStuff function", NULL,
PYTHON_API_VERSION
        );

}

When I compile, I get two warnings..which are ok.  Then when I build my
DLL I get..

Linking...
   Creating library Release/MyDLL.lib and object Release/MyDLL.exp
test.obj : error LNK2001: unresolved external symbol _PyBuildValue
Release/MyDLL.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

MyDLL.dll - 2 error(s), 0 warning(s)

..Any ideas?

Diez B. Roggisch wrote:
> > PyObject *wrap_doStuff(PyObject *, PyObject *args) {
>                                   ^^^^^
> I guess you need a parameter name here....
> 
> 
> Diez




More information about the Python-list mailing list