所以这是我第一次尝试在 C++ 程序中使用 python,我在链接库时遇到了一些问题。
所以我使用带有 GNU GCC 编译器的 Code Blocks IDE,我有以下主程序:
#include <Python.h>
#include <iostream>
using namespace std;
int main()
{
cout<<"starting interpreter."<<endl;
Py_Initialize();
PyRun_SimpleString("print 'Im in python!'");
Py_Finalize();
return 0;
}
我的链接设置如下(在编译器和调试器设置的代码块 GUI 中):
linker settings:
link libraries:
C:\Python27\libs\libpython27.a
search directories:
linker:
C:\Python27\libs
有什么我想念的吗?还是我这样做是错误的?
构建消息:
C:\Users\users_name\Desktop\PythonIntegratedTest\main.cpp|1|error: Python.h: No such file or directory|
C:\Users\users_name\Desktop\PythonIntegratedTest\main.cpp||In function 'int main()':|
C:\Users\users_name\Desktop\PythonIntegratedTest\main.cpp|9|error: 'Py_Initialize' was not declared in this scope|
C:\Users\users_name\Desktop\PythonIntegratedTest\main.cpp|10|error: 'PyRun_SimpleString' was not declared in this scope|
C:\Users\users_name\Desktop\PythonIntegratedTest\main.cpp|11|error: 'Py_Finalize' was not declared in this scope|