我想使用嵌入在 c++ 应用程序中的 python。这是我的代码:
#include <Python.h>
int
main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]);
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
return 0;
}
我已包含在 c:\log\python27\include 中以获取 Python.h 以及 c:\log\python27\libs 以具有安装在 c:\log\python27 中的相应 python 链接库它正在编译但不是链接...为什么?我总是有以下错误:
main.o:main.cpp:(.text+0x17): undefined reference to `_imp__Py_SetProgramName'
main.o:main.cpp:(.text+0x1e): undefined reference to `_imp__Py_Initialize'
main.o:main.cpp:(.text+0x34): undefined reference to `_imp__PyRun_SimpleStringFlags'
main.o:main.cpp:(.text+0x3b): undefined reference to `_imp__Py_Finalize'