Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:p 40': 0.04; 'pointer': 0.05; 'definitions': 0.07; 'statically': 0.07; 'python': 0.08; 'declarations': 0.09; 'dynamically': 0.09; 'subject:python': 0.11; 'declaration': 0.16; 'from:name:mark hammond': 0.16; 'pointers': 0.16; 'pyobject': 0.16; 'pyobject*': 0.16; 'python.h': 0.16; 'received:192.168.0.9': 0.16; 'reply- to:addr:mhammond': 0.16; 'reply-to:addr:skippinet.com.au': 0.16; 'subject:required': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'help.': 0.19; 'cc:no real name:2**0': 0.20; 'trying': 0.21; '(but': 0.21; 'subject:help': 0.22; 'cc:2**0': 0.22; 'header:In- Reply-To:1': 0.22; 'pm,': 0.24; 'code': 0.25; 'load': 0.26; 'tried': 0.26; "i'm": 0.27; 'function': 0.27; 'correct': 0.28; 'compile': 0.29; 'convention': 0.29; 'fine.': 0.29; 'script': 0.29; 'cc:addr:python.org': 0.30; 'fails.': 0.30; 'unable': 0.31; 'version': 0.32; 'hi,': 0.32; 'installed': 0.32; 'probably': 0.33; 'there': 0.33; 'copying': 0.33; 'calling': 0.33; 'done': 0.34; 'header:User-Agent:1': 0.34; 'message-id:@gmail.com': 0.34; 'idea': 0.34; 'subject:project': 0.34; 'problems': 0.36; 'facing': 0.37; 'using': 0.37; 'run': 0.37; 'but': 0.37; 'two': 0.37; 'could': 0.38; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'received:192': 0.39; 'returned': 0.39; 'getting': 0.39; 'basic': 0.39; 'define': 0.39; 'header': 0.39; 'might': 0.40; 'where': 0.40; 'target': 0.61; 'link': 0.63; 'here': 0.65; 'taking': 0.66; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'complies': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=2uJfnrcID5CAiWiaI+ZpCGj2vH2s2Sc7YnhH0/7kY+k=; b=lbxsw7D1CWgzUi9eT75F3Xvit0H6EU/HLM/blGJ1ymAtVQyN1Z9O5Q87FlpNL5TT/K n3s3VwUjIXTV24Uev7NfhtPLY0syLw8jMkV6fhkiI1+2wHdCJuhtOdqNPneZLa37Dw3l LZ37RX//yPaP+e+2GJksvGW9UVY8uX+YyvOaQ= Date: Sat, 06 Aug 2011 16:55:28 +1000 From: Mark Hammond User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: mrinalini@edss.co.in Subject: Re: Dynamically linking python into my vc project - help required References: <6cafe6745022b37909647db99073fc87@edss.co.in> In-Reply-To: <6cafe6745022b37909647db99073fc87@edss.co.in> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: mhammond@skippinet.com.au List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312613756 news.xs4all.nl 23944 [2001:888:2000:d::a6]:59999 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10957 On 3/08/2011 6:58 PM, mrinalini@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