473,654 Members | 3,022 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_SimpleStr ing("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@linuxA ddict TA]$ c++ temp.c -I /usr/include/python2.2/
/tmp/ccnpr9em.o(.tex t+0x11): In function `main':
: undefined reference to `Py_Initialize'
/tmp/ccnpr9em.o(.tex t+0x1e): In function `main':
: undefined reference to `PyRun_SimpleSt ring'
/tmp/ccnpr9em.o(.tex t+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,Hyder abad 500019

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

Jul 18 '05 #1
0 1115

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

Similar topics

0
1359
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 plugin, and now it crashes. My plugin do the following things: Py_Initialize(); LoadLibrary("pythoncom23.dll"); typedef PyObject* (*CONVERT_PROC)(IUnknown *punk, REFIID riid, BOOL
0
1351
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 subclass of tuple)
2
3179
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 Viewer) Since I create the SVG dynamicaly the WIDTH and HEIGHT is unknown, when loading the HTML page. Can I embed SVG like I can do it with images without defining WIDTH and HEIGHT. Simply "oversize" both attributes unnecessarily produces scrollbars in the browser window.
3
1825
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 condition. What I need to do is to change the value in Field9 in tblOne for all the records found by the query. I am not sure if I should use an update query or if I use some vba code. In case I will have to use an update query, is there a way to disable the warning prompts of it? (Or any...
7
2207
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 graphical. i have few questions regarding MS SQL 2000 1. what is the best (or easiest) way of getting a table definition in text? it could be either a CREATE TABLE sql-query or a just a definition, something like: TABLE thisTable id integer
0
910
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, text="Hello, world!") w.pack()
3
1851
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? 2. Does it support setting of QoS flags? 3. Does it support tunneling of IPv6 on a IPv4 network? 4. If an IPv4 address is given, does it support this on a IPv6 network? If not can you kindly let me know, Are there any plans for supporting these features in future?
0
1322
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 c:\mingw and python is in c:\pyton24. there is also python24.lib and libpython24.a in c:\python24\libs. when I try to compile this sample code from with command in msys shell I get the results . this subject was discussed a few times over these years and I tried everything in the posts and...
1
1229
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 another while first one is not completed then both songs are playing that do not i want ... i want like at time only one shog should play. Is there any scripting to do this? I am giving the code which i have embed
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.