【发布时间】:2013-09-30 08:44:34
【问题描述】:
我想使用嵌入在 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'
【问题讨论】:
-
您似乎没有提供 Python.h 源文件
-
不,我有与您的命令完全相同的链接错误!难以置信,我现在真的不知道该尝试什么!!?