query regarding embeding python in C

Vardhman Jain vardhman at students.iiit.net
Wed Apr 7 11:48:21 EDT 2004


Hi,
	No replies. I need it urgently please help!!!!


Vardhman

On Wed, 7 Apr 2004, Vardhman Jain wrote:

> Date: Wed, 7 Apr 2004 14:36:32 +0530 (IST)
> From: Vardhman Jain <vardhman at students.iiit.net>
> To: python-list at python.org
> Subject: query regarding embeding python in C
> 
> Hi,
> 	I am trying out the concept of python code being executed from a C 
> program. I got a peice of code from the tutorial but I don't know how to 
> compile/use it
> 
> The code is
> #include <Python.h>
> 
> int
> main(int argc, char *argv[])
> {
>       Py_Initialize();
>         PyRun_SimpleString("from time import time,ctime\n"
>                                      "print 'Today is',ctime(time())\n");
>           Py_Finalize();
>             return 0;
> }
> ~
> ~
> 
> 
> Now If I do "c++ temp.c -I /usr/include/python2.2/" I get the errors
> [vardhman at linuxAddict TA]$ c++ temp.c  -I /usr/include/python2.2/
> /tmp/ccnpr9em.o(.text+0x11): In function `main':
> : undefined reference to `Py_Initialize'
> /tmp/ccnpr9em.o(.text+0x1e): In function `main':
> : undefined reference to `PyRun_SimpleString'
> /tmp/ccnpr9em.o(.text+0x26): In function `main':
> : undefined reference to `Py_Finalize'
> collect2: ld returned 1 exit status
> 
> Can some one tell me how to compile and use this code.
> 
> 
> Vardhman
> 
> 
>  -- 
> Vardhman Jain
> III Year B.Tech. CSE
> IIIT-Hyderabad
> Address:
> Room No 27, NBH, IIIT-Hyderabad,Hyderabad 500019
> 
> presence on net:
>     http://students.iiit.net/~vardhman
> 
> 
> 
> 

-- 
Vardhman Jain
III Year B.Tech. CSE
IIIT-Hyderabad
Address:
Room No 27, NBH, IIIT-Hyderabad,Hyderabad 500019

presence on net:
    http://students.iiit.net/~vardhman






More information about the Python-list mailing list