I'm following The Code Project's tutorial on embedding Python and it's all going well until I start to make function visible to the interpreter. Like:
I get the link error:Code:#include <iostream> #include <py/python.h> static int g_iNumArgs = 0; static PyObject* emb_NumArgs(PyObject* poSelf, PyObject* poArgs) { if (! PyArg_ParseTuple(poArgs, ":g_iNumArgs")) return 0; return Py_BuildValue("i", g_iNumArgs); } static PyMethodDef EmbMethods[] = { {"NumArgs", emb_NumArgs, METH_VARARGS, "Return the number of arguments received by the process."}, {0, 0, 0, 0} }; int main(int argc, char* argv[]) { Py_Initialize(); g_iNumArgs = argc; Py_InitModule("emb", EmbMethods); Py_Finalize(); return 0; }
I'm linking python24.lib and I've tried all the others that come with the installation but nothing is working. Can anyone help?Code:PyEmbed.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs referenced in function _main
EDIT: Oh... yeah I didn't have python24_d.lib (apparently it doesn't come with the installation) so I just made a copy of python24.lib and renamed it... like an idiot. I just ran a Release and it works fine.
Off hunting for the _d version.
EDIT2: Well that's not happening (getting hold of it) so I'll just #undef _DEBUG. I don't like it though...



LinkBack URL
About LinkBacks


