Python论坛  - 讨论区

标题:[python-chinese] 答复: c与python交互

2006年09月12日 星期二 00:42

asong asong43在sohu.com
星期二 九月 12 00:42:23 HKT 2006

‹ÜëBâžH§€²
)ö­jW«®ŠË4­uӇžz-¢—§~)^§+a¢}·vX›ºè­ì^rëbž	bžG±zÖ§‘ì^Õê뢻4ÁªçŠx,N§’ÃږŠr¶'r§zǛ¢éÜzÉb²Û)ÊØhÉæj)m¢œ­†‰Ü†)Þ±æèºw²X¬¶Êr¶'rxÞ®¼¶ÓN¸ë]<§+a¢w!Šw¬zX¬¶Êr¶'rt^§+a¢w!Šw¬yÊr¶'öãa¶Úlÿü0ë(~Ü­è›™Ê&ýׯzZ)z¼(®K?yۜjبŸùiÊØhžÇ+Š›Šw^Æf–)ܖç^?+a¢x
·šµæŸºw-Š‰í¢§vWž®º+³^žØ^ʇº¿ï¢'^®º+r«zºì¶¸§‚šâž×ìêë²Úâž±ŠÝbžÙšŠÒzÛ©¶¯j¸šnW¬¶ˆh•Ùž¶±û§rبžÆ§uÉZ²È§²Ö§qëj·§…è­Â)e†‰]¢êëzÛ«žö¥¹ïÏÈæãyËkzÙ²š‡\•«,™ëa¡Ö«‚ʍç-~Zµö«zx^ŠÓò"x­‰©bÍïË¡§hº¹¨vé^þl¦¡Óò"jh®Ò&¦Ší2‡n•ç–È®³òÁçhžØµ£ò¶'¡¸ÞrÖÚrKaz·°jÆ©®†åzoâ~l¦¡

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 08:26

风尘无限 tianyu263在163.com
星期二 九月 12 08:26:26 HKT 2006

asong:

	没有找到Python的Debug连接库文件。
可以自己用Python的源代码编译一个出来;
也可以把你程序的编译连接方式改为Release方式(就是用发布方式的,不要Debug信息的)。

        致
礼!
 
				 
        风尘无限
               Bejing HATL Information Technology Co. Ltd.
        tianyu263在163.com
          2006-09-12 08:23:46

= = = = = = = = = = = = = = = = = = = =
======= 2006-09-12 00:37:41 您在来信中写道:=======

>HI ,
>
>         我看到这个例子,在vc6.0下编译怎么出现这样的错误,我哪里设置有问题
>么?
>
>Linking...
>
>LINK : fatal error LNK1104: cannot open file "python23_d.lib"
>
>Error executing link.exe.
>
> 
>
>tank.exe - 1 error(s), 0 warning(s)
>
> 
>
>Thanks!
>
>Palo
>
> 
>
>  _____  
>
>发件人: python-chinese-bounces在lists.python.cn
>[mailto:python-chinese-bounces在lists.python.cn] 代表 jerry
>发送时间: 2006年4月6日 1:08
>收件人: python-chinese在lists.python.cn
>主题: Re: [python-chinese] c与python交互
>
> 
>
>从网上看到的一个例子(有C代码和PYTHON代码),应该可以解决你的问题。
>
>https://www6.software.ibm.com/developerworks/education/l-pythonscript/index.
>html
>
> 
>
>#include 
>
>/* Create a function to handle errors when they occur */
>void error(char errstring)
>{
>  printf("%s\n",errstring);
>  exit(1);
>}
>
>int main()
>{
>/* Set up the variables to hold methods, functions and class 
>   instances. farenheit will hold our return value */
>  PyObject *ret, *mymod, *class, *method, *args, *object;
>  float farenheit;
>
>  Py_Initialize();
>
>/* Load our module */
>  mymod = PyImport_ImportModule("celsius"); 
>
>/* If we dont get a Python object back there was a problem */
>  if (mymod == NULL)
>    error("Can't open module");
>
>/* Find the class */
>  class = PyObject_GetAttrString(mymod, "celsius"); 
>
>/* If found the class we can dump mymod, since we won't use it
>   again */
>  Py_DECREF(mymod);
>
>/* Check to make sure we got an object back */
>  if (class == NULL)
>    {
>      Py_DECREF(class); 
>      error("Can't find class");
>    }
>
>/* Build the argument call to our class - these are the arguments
>   that will be supplied when the object is created */
>  args = Py_BuildValue("(f)", 100.0);
>
>  if (args == NULL)
>    {
>      Py_DECREF(args);
>      error("Can't build argument list for class instance");
>    }
>
>/* Create a new instance of our class by calling the class
>   with our argument list */
>  object = PyEval_CallObject(class, args);
>  if (object == NULL)
>    {
>      Py_DECREF(object);
>      error("Can't create object instance");
>    }
>
>/* Decrement the argument counter as we'll be using this again */ 
>  Py_DECREF(args);
>
>/* Get the object method - note we use the object as the object
>   from which we access the attribute by name, not the class */
>  method = PyObject_GetAttrString(object, "farenheit"); 
>
>  if (method == NULL)
>    {
>      Py_DECREF(method);
>      error("Can't find method");
>    }
>
>/* Decrement the counter for our object, since we now just need
>   the method reference */ 
>  Py_DECREF(object);
>
>/* Build our argument list - an empty tuple because there aren't
>   any arguments */
>  args = Py_BuildValue("()");
>
>  if (args == NULL)
>    {
>      Py_DECREF(args); 
>      error("Can't build argument list for method call");
>    }
>
>/* Call our object method with arguments */
>  ret = PyEval_CallObject(method,args);
>
>  if (ret == NULL)
>    {
>      Py_DECREF(ret); 
>      error("Couldn't call method");
>    }
>
>/* Convert the return value back into a C variable and display it */
>  PyArg_Parse(ret, "f", &farenheit;);
>  printf("Farenheit: %f\n", farenheit); 
>
>/* Kill the remaining objects we don't need */
>  Py_DECREF(method);
>  Py_DECREF(ret);
>
>/* Close off the interpreter and terminate */
>  Py_Finalize();
>  return 0;
>}
>       
>
>/////////////////
>
>class celsius:
>    def __init__(self, degrees):
>        self.degrees = degrees
>    def farenheit(self):
>        return ((self.degrees*9.0)/5.0)+32.0
>
>
>
> 
>
>On 4/5/06, Robert Chen <search.pythoner在gmail.com> wrote: 
>
>我建议你还是用正统的Python的C扩展方式,用一个C的dll包装你的C++的class,呵
>呵,这个不会耽误你太多时间 :)
>
>On 4/5/06, 吴俊玉 < wujunyu在gmail.com wujunyu在gmail.com> > wrote: 
>
>要崩溃了!
>
> 
>
>今天又看了一些boost,确实看到了一些例子能够把类封装成python模块,
>
>天哪,还是使用bjam的,以前就没有手写过makefile,等于又要学一样工具
>
>我又晕头转向编译了一下boost,
>
> 
>
>还是使用dll的――我可不想使用dll的方式
>
>而且boost的这种方式让我害怕
>
>时间不多了,还有5天要完成编码了!
>
>明天看一下boost。python源码吧!希望有帮助、
>
> 
>
> 
>
>
>
>
>
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>python-chinese在lists.python.cn> 
>Subscribe: send subscribe to python-chinese-request在lists.python.cn 
>Unsubscribe: send unsubscribe to   python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>
>
>-- 
>Robert
>Python源码剖析――http://blog.donews.com/lemur/ 
>
>
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn 
>Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
> 
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese




[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 08:49

Darren snlee99在tom.com
星期二 九月 12 08:49:09 HKT 2006

On 09/12/2006 at 00:42, asong wrote:

> HI ,
>
>          我看到这个例子,在vc6.0下编译怎么出现这样的错误,我哪里设置有问题
> 么?
>
> Linking...
>
> LINK : fatal error LNK1104: cannot open file "python23_d.lib"
>
> Error executing link.exe.
>
>  
>
> tank.exe - 1 error(s), 0 warning(s)

#undef _DEBUG
#include 
#define _DEBUG


-- 
(reply-to (concat "snlee99" "@" "tom" "." "com"))


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月12日 星期二 09:02

刘鑫 march.liu在gmail.com
星期二 九月 12 09:02:27 HKT 2006

Ò²¿ÉÒÔ±àÒëÒ»¸ödebug°æµÄÁ´½Ó¿â¡£

2006/9/12, Darren <snlee99在tom.com>:
>
> On 09/12/2006 at 00:42, asong wrote:
>
> > HI ,
> >
> >          ÎÒ¿´µ½Õâ¸öÀý×Ó£¬ÔÚvc6.0ϱàÒëÔõô³öÏÖÕâÑùµÄ´íÎó£¬ÎÒÄÄÀïÉèÖÃÓÐÎÊÌâ
> > ô£¿
> >
> > Linking...
> >
> > LINK : fatal error LNK1104: cannot open file "python23_d.lib"
> >
> > Error executing link.exe.
> >
> >
> >
> > tank.exe - 1 error(s), 0 warning(s)
>
> #undef _DEBUG
> #include 
> #define _DEBUG
>
>
> --
> (reply-to (concat "snlee99" "@" "tom" "." "com"))
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese




-- 
»¶Ó­·ÃÎÊ£º
http://blog.csdn.net/ccat

ÁõöÎ
March.Liu
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20060912/6c4eefa3/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2006年09月13日 星期三 00:30

asong asong43在sohu.com
星期三 九月 13 00:30:22 HKT 2006

En,改成release版本编译就好了,谢谢大家了,

Debug 版本的编译库明天编译一个再试试。

 

Thanks!

Palo

  _____  

发件人: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn] 代表 刘鑫
发送时间: 2006年9月12日 9:02
收件人: python-chinese at lists.python.cn
主题: Re: [python-chinese] 答复: c与python交互

 

也可以编译一个debug版的链接库。

2006/9/12, Darren <snlee99 at tom.com>:

On 09/12/2006 at 00:42, asong wrote:

> HI ,
>
>          我看到这个例子,在vc6.0下编译怎么出现这样的错误,我哪里设置有问题
> 么?
>
> Linking...
>
> LINK : fatal error LNK1104: cannot open file "python23_d.lib" 
>
> Error executing link.exe.
>
>
>
> tank.exe - 1 error(s), 0 warning(s)

#undef _DEBUG
#include 
#define _DEBUG


--
(reply-to (concat "snlee99" "@" "tom" "." "com")) 

_______________________________________________
python-chinese
Post: send python-chinese at lists.python.cn
Subscribe: send subscribe to python-chinese-request at lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese




-- 
欢迎访问:
http://blog.csdn.net/ccat

刘鑫
March.Liu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20060913/d8555157/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号