将 python 与 c++ 接口
Interfacing python with c++
我正在尝试将python与C++接口。我正在使用Visual Studio Express 2012。我还有一个 enthought python 2.7 发行版。当我尝试使用以下代码在 Win 32 上构建版本时:
#include "stdafx.h"
#include "C:/Python27/include/Python.h"
#include "C:/Python27/Lib/site-packages/numpy/core/include/numpy/arrayobject.h"
using namespace std;
int main( int argc, char* argv[] )
{
int x = 1;
PyObject *mod1;
Py_Initialize();
return 0;
}
我收到以下错误:
Error 1 error LNK2001: unresolved external symbol __imp__Py_Initialize
请帮忙,任何想法都非常欢迎。
应将C:Python27libs
添加到库路径中,并将python27.lib
添加到依赖项中。
为此:
Go to project properties -> Configuration properties -> Linker.
Go to ->General and set the "Additional Library directories"
在此字段中,您可以添加C:Python27libs
。
然后:
Go to Linker -> Input and set the "Additional Dependencies"
在此字段中,您可以添加python27.lib
。
此外,您还应该将C:Python27include
添加到包含目录中,然后执行以下操作:
#include <Python.h>
我认为您尝试将 64 位 python 库链接到 32 位应用程序
相关文章:
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- Visual C++GC接口如何启用它以及要包含哪个库
- Windows.h与GLFW.h的接口
- 当字段可以为null时,如何使用C++接口在Avro中写入数据
- 提供与TMP和SFINAE的通用接口
- 为重写std::exception的库生成swig接口时出错
- 内联如何影响模块接口中的成员函数
- COM 接口 c# 封送数组数组
- 如何在 SCIP C++ 接口中获取 MILP 约束矩阵中的系数值
- 重载 -> shared_ptr 个实例中的箭头运算符<interface>,接口中没有纯虚拟析构函数
- 如何绑定 C++ gRPC 客户端的网络接口
- 模板化接口 - 创建一个泛型模板类以返回任何容器
- 如何从实现接口的模板化类实例访问结构
- 带有进度表的 curl 多接口程序
- 设计帮助 - 为不同类型的消息处理通用接口的设计模式
- 我可以在具有一个标头和一个接口的 cpp 文件中有多个嵌入吗?
- 类接口,可以创建N个方法
- 类具有相同的接口,但参数的类型不同
- 如何与 Cheerp/js 中的 extern 变量接口?
- 如何使用现代 CMake 安装捆绑的接口依赖项?