Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-04-2008, 07:07 AM
BlueDream BlueDream is offline
Newbie
 
Join Date: May 2008
Posts: 4
Credits: 0
Rep Power: 0
BlueDream is on a distinguished road
Default Using python in C

Hi,

I'm trying to wrap my head around piping in C - I've got a small C program that forks and pipes stuff from the child process to the parent process.

Currently the child process calls a C program that squirts out random numbers which then pipes the result to the parent process.

The parent process reads the pipe and simply prints the random number.

What I would like to do is then use this piped integer in a python program.

So firstly I think I have to include the python library within the C program.

#include <python2.4/Python.h>

then call python with:

Py_Initialize();

But when I call this the gcc compiler gives me the error:
undefined reference to 'Py_Initialize'

So I'm guessing that the header file I'm using is incorrect..?

the python version I'm using is:

Python 2.4.3 (#1, Jun 13 2006, 16:41:18)

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-04-2008, 07:17 AM
v0id's Avatar   
v0id v0id is offline
Super Moderator
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,566
Last Blog:
CherryPy(thon)
Credits: 50
Rep Power: 28
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default Re: Using python in C

Did you remember to link with the Python library?
If you're using GCC, add "-lpython2.4"
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

I'm always up for a chat, so feel free to contact me...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-04-2008, 09:02 AM
BlueDream BlueDream is offline
Newbie
 
Join Date: May 2008
Posts: 4
Credits: 0
Rep Power: 0
BlueDream is on a distinguished road
Default Re: Using python in C

Hmmn, no I wasn't linking it on the command line with gcc.

I tried the example you gave.

:\gcc pipe.c -lpython2.4

and voila!

My code is not working, but at least I can see it's getting past that darn udefined variable problem.

Now all I need to do is figure out how to print the variable in python with PyRun_SimpleString( ..... ).

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to learn Python. Sir_Rimo Python 21 08-22-2008 08:16 AM
Python for developing software Kasper Python 8 08-06-2008 11:11 PM
Python Visual Interface Midnight Python 6 04-19-2008 12:56 AM
Splitting Strings with Empty Separator (Python) Matt Python 3 05-18-2007 12:27 PM
Python Collection reachpradeep Python 1 03-03-2007 02:50 PM


All times are GMT -5. The time now is 12:35 AM.

Contest Stats

Xav ........ 1024.41
MeTh0Dz|Reb0rn ........ 974.08
morefood2001 ........ 850.04
John ........ 841.93
WingedPanther ........ 661.52
marwex89 ........ 575.59
Brandon W ........ 447.93
chili5 ........ 292.12
orjan ........ 187.41
Steve.L ........ 181.88

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 79%

Ads