带有C ++的简单SWIG用于python编译,但输出似乎不正确?

问题描述 投票:0回答:1

我对SWIG(和C ++)还很陌生,所以我尝试使用示例from this website似乎是一个简单的代码。我在Visual Studio上成功编译了(我认为?)。

1>------ Rebuild All started: Project: minimal, Configuration: Release x64 ------
1>Performing Custom Build Tools
1>minimal.cpp
1>minimal_wrap.cxx
1>   Creating library ..._minimal2.lib and object ...minimal2.exp
1>Generating code
1>Previous IPDB not found, fall back to full compilation.
1>All 70 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
1>Finished generating code
1>minimal.vcxproj -> C:\...\_minimal.pyd
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

但是当我尝试在spyder(ipython控制台)上运行它时>

import _minimal
m1 = minimal.minimal()
print(m1)

输出<minimal.minimal; proxy of <Swig Object of type 'minimal2 *' at 0x000001D0C68BDDE0>

从教程网站,听起来我应该得到一些整数?

m1.print_num_instances()

此命令导致无输出...我的文件构建不正确吗?

我对SWIG(和C ++)还很陌生,所以我试图使用本网站的示例,这似乎是一个简单的代码。我在Visual Studio上成功编译了(我认为?)。 1> ------全部重建...

python c++ visual-studio spyder swig
1个回答
0
投票

所以看起来我不得不添加“ typemaps.i”并定义输出类型。我没有处理上面的问题中使用的示例,但是我发现another example非常有用。

© www.soinside.com 2019 - 2024. All rights reserved.