Re: [Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Varsha Purohit
I am gettng following linking errors

  [Linker error] undefined reference to `_imp__Py_Initialize'
  [Linker error] undefined reference to `PyRun_SampleString'
  [Linker error] undefined reference to `_imp__Py_Finalize'

I think i need to set the path to the linker... may be i need to pass
linking options of python to the c compiler... but wat are those options :(
??

On Jan 20, 2008 7:16 AM, Alan Gauld <[EMAIL PROTECTED]> wrote:

>
> "Varsha Purohit" <[EMAIL PROTECTED]> wrote
>
> >   I just read about how to call python from a c program.
>
> Where did you read it? There are several sources of info
> on embedding Python in C, some better than others.
>
> > And how can i call the python interpreter screen
> > from c program ??
>
> You don't call the python interpreter screen
> (ie the >>> prompt) from C you call the interpreter itself.
> The interactive interpreter is a C program in its own right.
>
> You could write your own fairly easily or you could use
> the PyShell GUI component that is part of the wxPython
> package.
>
> But usually you just want to interpret some Python
> commands much as you did in your example.
>
> HTH,
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Alan Gauld

"Varsha Purohit" <[EMAIL PROTECTED]> wrote

>   I just read about how to call python from a c program. 

Where did you read it? There are several sources of info 
on embedding Python in C, some better than others.

> And how can i call the python interpreter screen 
> from c program ??

You don't call the python interpreter screen
(ie the >>> prompt) from C you call the interpreter itself.
The interactive interpreter is a C program in its own right.

You could write your own fairly easily or you could use 
the PyShell GUI component that is part of the wxPython 
package.

But usually you just want to interpret some Python 
commands much as you did in your example.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Kent Johnson
Varsha Purohit wrote:
> I got the python.h file but i am getting linking errors for my program

It might help to tell us
- what platform you are using
- what compiler
- what link errors

Kent

> 
> On Jan 20, 2008 1:18 AM, Varsha Purohit <[EMAIL PROTECTED] 
> > wrote:
> 
> Hi,
>I just read about how to call python from a c program. This is
> the function for that
> 
> int main()
> {
>  Py_Initialize();
> PyRun_SampleString("print 76");
> Py_Finalize();
>
> return 0;
> }
> 
> 
> But i am getting an error of header file. python.h not found. Can
> anybody tell me where can i get this header file ?? And how can i
> call the python interpreter screen from c program ??
> 
> -- 
> Varsha Purohit,
> Graduate Student 
> 
> 
> 
> 
> -- 
> Varsha Purohit,
> Graduate Student
> 
> 
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Varsha Purohit
I got the python.h file but i am getting linking errors for my program

On Jan 20, 2008 1:18 AM, Varsha Purohit <[EMAIL PROTECTED]> wrote:

> Hi,
>I just read about how to call python from a c program. This is the
> function for that
>
> int main()
> {
>  Py_Initialize();
> PyRun_SampleString("print 76");
> Py_Finalize();
>
> return 0;
> }
>
>
> But i am getting an error of header file. python.h not found. Can anybody
> tell me where can i get this header file ?? And how can i call the python
> interpreter screen from c program ??
>
> --
> Varsha Purohit,
> Graduate Student




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Varsha Purohit
Hi,
   I just read about how to call python from a c program. This is the
function for that

int main()
{
 Py_Initialize();
PyRun_SampleString("print 76");
Py_Finalize();

return 0;
}


But i am getting an error of header file. python.h not found. Can anybody
tell me where can i get this header file ?? And how can i call the python
interpreter screen from c program ??

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor