Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要使用C+;扩展Python3.2的帮助吗+;模块 有人对如何用C++来扩展Python 3有什么建议吗?我尝试过使用SWIG,但在尝试访问我的计算机上不存在的库文件(Python_d.lib或类似文件)时,它出现了一个致命的链接错误_C++_Python_Swig - Fatal编程技术网

需要使用C+;扩展Python3.2的帮助吗+;模块 有人对如何用C++来扩展Python 3有什么建议吗?我尝试过使用SWIG,但在尝试访问我的计算机上不存在的库文件(Python_d.lib或类似文件)时,它出现了一个致命的链接错误

需要使用C+;扩展Python3.2的帮助吗+;模块 有人对如何用C++来扩展Python 3有什么建议吗?我尝试过使用SWIG,但在尝试访问我的计算机上不存在的库文件(Python_d.lib或类似文件)时,它出现了一个致命的链接错误,c++,python,swig,C++,Python,Swig,编辑: 我采取的步骤是: 1) 从下载swigwin-2.0.4 2) 设置环境变量(PYTHON_INCLUDE和PYTHON_LIB) 3) 构建swigwin包中包含的示例之一。代码如下所示。这是在MVSC++2010中构建的 /* File : example.c */ #include "example.h" #define M_PI 3.14159265358979323846 /* Move the shape to a new location */ void Shape::

编辑:

我采取的步骤是:

1) 从下载swigwin-2.0.4

2) 设置环境变量(PYTHON_INCLUDE和PYTHON_LIB)

3) 构建swigwin包中包含的示例之一。代码如下所示。这是在MVSC++2010中构建的

/* File : example.c */

#include "example.h"
#define M_PI 3.14159265358979323846

/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
    x += dx;
    y += dy;
}

int Shape::nshapes = 0;

double Circle::area(void) {
    return M_PI*radius*radius;
}

double Circle::perimeter(void) {
    return 2*M_PI*radius;
}

double Square::area(void) {
    return width*width;
}

double Square::perimeter(void) {
    return 4*width;
}
我从中得到的输出的相关部分是:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\David\Downloads\swigwin-2.0.4\Examples\python\class\.\Debug\example.dll) does not match the Linker's OutputFile property value (C:\Users\David\Downloads\swigwin-2.0.4\Examples\python\class\_example.pyd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile property value (.pyd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(example) does not match the Linker's OutputFile property value (_example). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

1>LINK : fatal error LNK1104: cannot open file 'python32_d.lib'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.27

将生成配置从调试更改为在MSVC中发布,或检查的答案。

然后请询问如何解决该SWIG错误(输入您所做操作的详细信息,以及相关代码和确切的编译器错误)。仅仅因为你无法构建它并不意味着它不适合使用。正如@Mat所说,如果你发布了一个具体的问题(模块接口是什么样子的,你运行了什么来编译它,错误消息是什么),那么人们可以为你修复它。事实上,这个问题是非常模糊和开放的。这是事实,当时我在大学,没有详细的细节,我只是想看看其他人采取什么步骤让Python 3与C++一起工作。我已经将我能提供的所有信息添加到原始帖子中。非常感谢,该项目现在已经成功构建。我现在遇到的唯一问题是,它试图引用我正在处理的示例项目中不存在的dll。我会先亲自研究一下这个问题,但如果你能马上想到解决这个问题的办法,我会非常感激。如果您感兴趣:“无法启动程序‘C:\Users….\swigwin-2.0.4\Examples\python\class\.\Release\example.dll’。系统找不到指定的文件。”请检查项目的properties.Tagc中的链接器输入文件,您是如何解决此问题的?我也有同样的错误。我认为VS项目的重点是生成example.dll。。。这对我来说是不可能的。没关系,VS项目的重点是生成_example.pyd。我通过进入Build>Rebuild Solution修复了错误。