首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用c++接口python

用c++接口python
EN

Stack Overflow用户
提问于 2013-09-13 05:45:21
回答 2查看 261关注 0票数 1

我正在尝试将python与C++进行接口。我正在使用2012。我还有一个经过深思熟虑的python2.7发行版。当我试图用以下代码在Win 32上构建一个发行版时:

代码语言:javascript
复制
#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;
}

我得到以下错误:

代码语言:javascript
复制
Error   1   error LNK2001: unresolved external symbol __imp__Py_Initialize

请帮助,任何更多的想法欢迎。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-13 05:50:34

应该将C:\Python27\libs添加到库路径中,并将python27.lib添加到依赖项中。

为此:

代码语言:javascript
复制
Go to project properties -> Configuration properties -> Linker.
Go to ->General and set the "Additional Library directories"

在这个字段中添加C:\Python27\libs

之后:

代码语言:javascript
复制
Go to Linker -> Input and set the "Additional Dependencies"

在这个字段中添加python27.lib

此外,还应该将C:\Python27\include添加到包含目录中,只需:

代码语言:javascript
复制
#include <Python.h>
票数 1
EN

Stack Overflow用户

发布于 2013-09-13 06:04:21

我认为您试图将64位python库链接到32位应用程序。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18779104

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档