472,344 Members | 1,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,344 software developers and data experts.

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@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

Jul 18 '05 #1
0 1058

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fabien SK | last post by:
Hi, I wrote a plugin for Visual C++ 6 that uses Python 2.2 (it worked perfectly for months). I just installed Python 2.3, and recompiled my...
0
by: Brano Zarnovican | last post by:
Hi ! I need to import a module and create an instance of a class from that module (in C). import mod o = mod.klass() (mod.klass is a...
2
by: Sascha Kerschhofer | last post by:
Hi, I am embeding my SVG Files in HTML in this way: <OBJECT DATA="foo.svg" WIDTH="300" HEIGHT="200" TYPE="image/svg+xml"> (using Acrobat SVG...
3
by: Nicolae Fieraru | last post by:
Hi All, I have a select query which is based on tblOne and tblTwo. The query selects some of the records in tblOne and tblTwo, based on a Where...
7
by: stig | last post by:
hi. coming from postgresql, i am used to textual references to most of the things i do with the database. i feel a little lost with all the...
0
by: kiokju | last post by:
I want run Python GUI program on MFC. So I coded this def start(): global Tkinter from Tkinter import * root = Tk() w = Label(root,...
3
by: Pramod TK | last post by:
Hello All, I have some queries related to python support for IPv6. Can you kindly clarify the doubts which I have - 1. Does python support IPv6? ...
0
by: mani | last post by:
Hi I'm bringing up an old story once more! I'm on win32 (winxp sp2) python 2.4.4. mingw gcc version is 3.4.5. msys is in c:\msys. mingw is in...
1
by: tokcy | last post by:
Hi, I am embeding flash player in my site but i have some problem like... suppose i have 5 songs and i am playing one song but i want to play...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.