Help: "undefined reference to `PyArg_ParseTuple'" when execising 'Extending Python with C or C++ '

Lu Jian Xiong jxlu at fudan.edu.cn
Sun Apr 6 15:45:28 CEST 2003


Hello,
I am a newbie of python.
When I was trying the example read from the following URL,
http://www.python.org/doc/current/ext/simpleExample.html,
it showed the following error message:

[root at localhost user0]# gcc -I /usr/include/python2.2/ -L /usr/lib/python2.2/c
onfig/ -l python2.2 spammodule.c
/tmp/ccIl3dpq.o: In function `spam_system':
/tmp/ccIl3dpq.o(.text+0x16): undefined reference to `PyArg_ParseTuple'
/tmp/ccIl3dpq.o(.text+0x47): undefined reference to `Py_BuildValue'
collect2: ld returned 1 exit status
#
#I tried to find out the problem
[root at localhost user0]# slocate *.a|grep ython
/usr/lib/python2.2/config/libpython2.2.a
[root at localhost user0]# rpm -qa|grep ^python
python-docs-2.2.2-7
python-optik-1.3-2
python-tools-2.2.2-7
python-devel-2.2.2-7
python-2.2.2-7
[root at localhost user0]# cat spammodule.c
#include <Python.h>
static PyObject *
spam_system(self, args)
    PyObject *self;
    PyObject *args;
{
    char *command;
    int sts;

    if (!PyArg_ParseTuple(args, "s", &command))
        return NULL;
    sts = system(command);
    return Py_BuildValue("i", sts);
}
int main()
{
    return (0);
}
[root at localhost user0]#

What is the matter? What should I do?
Can you help me?

Excuse for my poor English.







More information about the Python-list mailing list