Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Python µÄCÓïÑÔÀ©Õ¹

²Ù×÷ϵͳ£ºlinux debian 4.0£¬ python°æ±¾2.5
s1:°²×°python2.5-dev¡£ÒòΪPython.hÊÇÔÚdev°üÖвÅÓС£
test@debian:~/test_python_c$ aptitude search python2.5-dev
p python2.5-dev - Header files and a static library for Python.
test@debian:~/test_python_c$ sudo aptitude install python2.5-dev
...
test@debian:~/test_python_c$ aptitude search python2.5-dev
i python2.5-dev - Header files and a static library for Python.
s2:×¼±¸²âÊÔÎļþ——CÓïÑÔº¯Êý
//filename:example.c
int fact(int n)
{
if(n<=1)
return 1;
else
return n*fact(n-1);
}

s3: ±àд·â×°½Ó¿Ú
//filename: wrap.c
#include <Python.h>
PyObject* wrap_fact(PyObject* self, PyObject* args)
{
int n, result;
if (! PyArg_ParseTuple(args, "i:fact", &n))
return NULL;
result = fact(n);
return Py_BuildValue("i", result);
}
static PyMethodDef exampleMethods[] =
{
{"fact", wrap_fact, METH_VARARGS, "Caculate N!"},
{NULL, NULL}
};
void initexample()
{
PyObject* m;
m = Py_InitModule("example", exampleMethods);
}

s4:±àÒëÁ¬½Ó
gcc -fpic -c -I /usr/include/python2.5 -I /usr/lib/python2.5/config example.c wrap.c
gcc -shared -o example.so example.o wrap.o
test@debian:~/test_python_c$ ls
example.c example.o example.so wrap.c wrap.o
s5:²âÊÔexampleÀ©Õ¹Ä£¿é
test@debian:~/test_python_c$ python
Python 2.5 (release25-maint, Jul 20 2008, 20:47:25)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import example
>>> dir(example)
['__doc__', '__file__', '__name__', 'fact']
>>> example.fact(5)
120
>>> example.fact(16)
2004189184
>>> example.fact(17)
-288522240

˵Ã÷fact(17)µÄʱºòÒç³öÁË¡£
²Ù×÷ϵͳ£ºwindowsXP£¬ python°æ±¾2.5
#TODO:


Ïà¹ØÎĵµ£º

zz Emacs C

ÈÕÆÚ£º2009-11-21   10:54:22
±¾½ÚÖ÷Òª²Î¿¼£º
    ²ÜÀֵġ¶ÔÚEmacsÏÂÓÃC/C++±à³Ì¡·
    Íõ´¿ÒµµÄ¡¶Emacs Ò»¸öÇ¿´óµÄƽ̨¡·
    emacswiki.org
emcasÄÑѧÒ×Ó㬿ÉÀ©Õ¹ÐÔÇ¿¡£ÓÐÈË°ÑËýµ±×÷ÐÅÑö£¬ÓÐÈËÈÏΪËûÊÇħ¹í£¡Ñ§Ï°Ê×ÏȼÇס»ù±¾µÄ¼üÅÌ¿ì½Ý¼ü£¬Ñ§»á³£Óòå¼þ£¬ ......

C/C++Èí¼þ¹¤³Ìʦ¾ÍÒµÇóÖ°ÊÖ²á½ÚÑ¡¶þ

 5¡¢#defineºê¶¨Òå¡£ºêÖ»ÊǼòµ¥µÄÎı¾Ìæ»»£¬ºÜÈÝÒ×ÒýÆðÆçÒå¡£
#include <stdio.h>
#define CONS(a,b) (int)(a##e##b)
#define STR(s) #s
int main()
{
   printf(STR(vck));
   printf("\n");
   printf("%d\n",CONS(2,3));
   return 0; ......

opencv python cool

µ±Äê×ö±ÏÒµÂÛÎĵÄʱºòopenCV¾ÍÏñÊÇÎÒµÄÈðÊ¿¾üµ¶£¬Ì«ÓиÐÇéÁË¡£Èç½ñÓÃÁËÒ»Äê¶àµÄpython£¬·¢ÏÖopenCVÒ²ÓÐpython°æ±¾ÁË£¬ÕæÊÇÌ«¿áÁË£¡µ±È»pythonÔÚ´¦ÀíͼÏñʱ»¹¿ÉÒÔÓÃÆäËü¿âÀýÈçPIL(Python Imaging Library )£¬Ò»ÖÖÇáÁ¿¼¶µÄͼÏñ¿â¡£Ä¿Ç°openCV1.0°æ±¾¶ÔÓ¦µÄpython°æ±¾Îª2.5£¬openCV2.0¶ÔÓ¦python 2.6¡£
¸½Â¼£º
1. һƪ½éÉÜͼ ......

Eclipse+PyDev = Python±à¼­Æ÷£¬

http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-pydev/Á¬½ÓÕâ¸öÍøÖ·£¬²»»áÈÃÄãʧÍûµÄ¡£
PyDev ¼ò½é
2003Äê7ÔÂ16ÈÕ£¬ÒÔ Fabio Zadrozny ΪÊ×µÄÈýÈË¿ª·¢Ð¡×éÔÚÈ«Çò×î´óµÄ¿ª·ÅÔ´´úÂëÈí¼þ¿ª·¢Æ½Ì¨ºÍ²Ö¿â SourceForge ÉÏ×¢²áÁËÒ»¿îеÄÏîÄ¿£¬¸ÃÏîĿʵÏÖÁËÒ»¸ö¹¦ÄÜÇ¿´óµÄ Eclipse²å¼þ£¬Óû§¿ÉÒÔÍêÈ«ÀûÓà Eclipse À ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ