Python论坛  - 讨论区

标题:[python-chinese] question about embeding python in c

2006年12月18日 星期一 14:59

weifeng xiao xnkjdx1998在yahoo.com.cn
星期一 十二月 18 14:59:51 HKT 2006

hi,everyone:
    i have a simple question,but i don't know why,thanks for your help

#include Python.h>
#include 
#include 
int main(int argc,char **argv){
    Py_Initialize();
    PyRun_SimpleString("print 1+8");
    Py_Finalize();
    return 0;
}
# libpython2.3.a located in usr/lib/python2.3/config/libpython2.3.a
#libpython2.3.so located in /usr/lib/libpython2.3.so
when compiled it like below(dynamic),it can work correctly,
gcc -o test -lpython2.3 test.c
while when compiled it like below(static),compile error
gcc -o test -static -lpython2.3 test.c -L /usr/lib/python2.3/config
why does error say:
/tmp/ccSmBEW1.o(.text+0x1d): In function `main':
: undefined reference to `Py_Initialize'
...
but in fact my libpython2.3.a located in /usr/lib/python2.3/config/libpython2.3.a
why?can anybody help me?

 __________________________________________________
¸Ï¿ì×¢²áÑÅ»¢³¬´óÈÝÁ¿Ãâ·ÑÓÊÏä?
http://cn.mail.yahoo.com
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061218/e6a253de/attachment.html 

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号