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

Lu Jian Xiong jxlu at
Sun Apr 6 15:45:28 CEST 2003

I am a newbie of python.
When I was trying the example read from the following URL,,
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
[root at localhost user0]# rpm -qa|grep ^python
[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