尝试运行:
#include <Python.h>
int
main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]); /* optional but recommended */
Py_Initialize();
PyRun_SimpleString("import IPython\n"
"IPython.embed()\n");
Py_Finalize();
return 0;
}
在Windwos 7下用mignw64 gcc 4.6.0(g++ -I /c/prog64/Python27/include t.cpp /c/prog64/Python27/libs/libpython27.a
)编译时,我得到错误:
请注意,PyRun_SimpleString
中的其他命令也可以工作;同样,在命令行python会话中:
import IPython
IPython.embed()
有效。在
我认为这个问题与MSVCR90.DLL有关,而MSVCR90.DLL正是这个函数所查找的,而且g++链接到“normal”的事实MSVCRT.DLL. 用VS2008编译不是一个简单的选择。在使用VS2010编译时会看到相同的错误消息。Python设置是Anaconda Python 2.7.8 64位。在
这个问题确实和msvcr90.dll有关。解决这个问题的方法是将程序链接到msvcr90.dll。但是,要链接到msvcr90.dll,您需要有一个清单,否则您将得到一个运行时错误。此清单看起来像:
我从中提取的python.exe使用一个名为
^{pr2}$msvcr90.manifest
的文本编辑器。此清单使用资源文件msvcr90.rc
链接到应用程序然后可以使用以下方法将其编译为对象文件:
然后,使用此资源文件和msvcr90.dll编译程序将变为:
我从c:/Windows/winsxs/amd64复制了msvcr90.dll_微软.vc90.crt_1fc8b3b9ae18e3b_9.0.21022.8_无\u 750b37ff97f4f68b/msvcr90.dll
对此的输入来自
还有一些其他的网页告诉我怎么做。在
相关问题 更多 >
编程相关推荐