Dynamically linking python into my vc project - help required
Mark Hammond
skippy.hammond at gmail.com
Sat Aug 6 02:55:28 EDT 2011
On 3/08/2011 6:58 PM, mrinalini at edss.co.in wrote:
> Hi,
>
> I am trying to embed python into my MFC application. I have done this
> before by statically linking to the python lib. But I want to change
> this now.
> The idea is to take the information from the registry for the installed
> version of python on the target machine. Then load python using
> loadlibrary call and use the functions from python using pointers to
> functions returned by GetProcAddress .
...
> PyObject* pObject = pFPyEval_EvalCode((PyCodeObject*)pCodeObject,
> m_Dictionary, m_Dictionary);
> }
>
>
> I am facing two problems here , though I want to link to python
> dynamically I am required to include python.h for my code to compile the
> following declaration.
>
> PyObject* pCodeObject
You can probably just define pFPyEval_EvalCode as taking a PyObject *
(but I'm not sure where you are getting a declaration of PyObject * from)
> I tried copying some of the python definitions including PyObject into a
> header in my mfc app. Then it complies fine. but Py_CompileString call
> fails. so finally I am unable to run script from my MFC application by
> linking to python dynamically.
Are you sure you have the calling convention correct on those function
pointer decls?
> How can this be done ? Please help. Is there a different approach to
> linking to python dynamically. Please could you write to me ?
py2exe takes the same basic approach as you and might be worth copying
its declarations for the function pointers?
Mark
More information about the Python-list
mailing list