0

I'm trying to embed python script in c in windows.

#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;
}

from the python documentation.
I'm compiling with Microsoft's lcc.
I'm getting following errors.

Error c:\lcc\examples\python\pyembed.c 7 undefined reference to __imp__Py_Initialize
Error c:\lcc\examples\python\pyembed.c 8 undefined reference to __imp__PyRun_SimpleStringFlags
Error c:\lcc\examples\python\pyembed.c 10 undefined reference to __imp__Py_Finalize

I added python include files in the project.But I'm not sure what to do with py27.lib or py27.dll.That may be the problem I guess.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by D33wakar
0

I don't know Microsoft's lcc, but you should probably link against the python library
(something like -lpy27 or -lpython ...). Also did you run the code in the linking requirements section

>>> import distutils.sysconfig
>>> distutils.sysconfig.get_config_var('LINKFORSHARED')

to get flags for the linker ?

0

yep I did

>>> import distutils.sysconfig
>>> distutils.sysconfig.get_config_var('LINKFORSHARED')

and it gave nothing.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.