swig

In SWIG compilation : In header file in interface is unable to resolve other header files.

北城以北 提交于 2019-12-05 13:10:55
In interface File. I have included a header file.In that Header file there are many header files included but from top tree bases But in Swig is not able to recognize those Eample: main.h #include<dir/second.h> #define PAGE 1 Swig is unable to resolve that dir in the header file Use -I<dir> on the SWIG command line to tell SWIG about include paths it doesn't know about. See SWIG 2.0 command line documentation SWIG normally does not process #include files recursively. The reason is you would not want SWIG to process every system header file. You can override this with -includeall , but that is

SWIG: No typemaps are defined

痴心易碎 提交于 2019-12-05 11:02:43
I have a c++ class that I am trying to wrap for Python using SWIG. I am having trouble trying to wrap one of the functions which takes an array as input. Here's the header file, class dyndiff_data_t { private: double H[3]; double GAMMA; double k; double P; public: dyndiff_data_t(double H_[3], const double GAMMA_, const double k_, const double P_); void test(); }; and here's the swig interface file, %module twowave %{ #define SWIG_FILE_WITH_INIT #include <twowave.h> %} %include "numpy.i" %init %{ import_array(); %} %apply (double IN_ARRAY1[3]) {(double H_[3])}; %include <twowave.h> The problem

Creating new classes/members at run-time in scripting languages used in C++ [closed]

点点圈 提交于 2019-12-05 09:35:19
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I've been working on this problem off and on for a few months, and now wanted to really come up with a proper solution that will handle the case of creating new user-defined classes (and instances of those classes) with member functions/properties at run-time in a C++11 project. So far, I've been using SWIG (formerly with Python, now with Lua, exploring Squirrel). Like all the C++ binding/embedding libraries I

SWIG python initialise a pointer to NULL

假装没事ソ 提交于 2019-12-05 07:52:52
Is it possible to initialise a ptr to NULL from the python side when dealing with SWIG module? For example, say I have wrapped a struct track_t in a swig module m (_m.so), I can create a pointer to the struct from python as follows: import m track = m.track_t() this will just malloc a track_t for me in the appropriate wrapper function. I would however like to be able to achieve the following: track_t *track = NULL; But in python rather than C, e.g. initialise a pointer to NULL from the python side I need to do this as it is a requirement of the hash table C implementation I am using that new

SWIG 3 中文手册——2. 引言

≡放荡痞女 提交于 2019-12-05 07:31:56
目录 2 引言 2.1 SWIG 是什么? 2.2 为什么使用 SWIG? 2.3 一个 SWIG 示例 2.3.1 SWIG 接口文件 2.3.2 swig 命令 2.3.3 构建 Perl5 模块 2.3.4 构建 Python 模块 2.3.5 快捷方式 2.4 支持的 C/C++ 语言特性 2.5 非直觉的接口构建 2.6 将 SWIG 整合进构建系统 2.7 自动化代码生成 2.8 SWIG 与自由 2 引言 2.1 SWIG 是什么? SWIG is a software development tool that simplifies the task of interfacing different languages to C and C++ programs. In a nutshell, SWIG is a compiler that takes C/C++ declarations and creates the wrappers needed to access those declarations from other languages including Perl, Python, Tcl, Ruby, Guile, and Java. SWIG normally requires no modifications to existing code

Accessing an array of pointers within a structure from Java with SWIG

送分小仙女□ 提交于 2019-12-05 07:00:50
I've something like this: typedef struct { char * content; } Boo; typedef struct { Boo **data; int size; } Foo; I want to convert Boo ** data to an array with Boo elements ( Boo[] ) in Java with SWIG. And then to read the array (I don't want to edit,delete and create a new array from Java code). In the SWIG documentation is described how to do this with carrays.i and array_functions , but the struct's member data must be of type Boo* . Is there a solution of my problem? EDIT: I've hurried and I've forgotten to write that I want to generate Java classes with SWIG to cooperate with C structures.

Bug writing audio using custom video writer library

≯℡__Kan透↙ 提交于 2019-12-05 05:54:35
I'm trying to wrap a little handy piece of C++ code that is intended to generate video+audio on windows using VFW, the C++ library lives here and the descriptions says: Uses Video for Windows (so it's not portable). Handy if you want to quickly record a video somewhere and don't feel like wading through the VfW docs yourself. I'd like to use that C++ library on Python so I've decided to wrap it up using swig. Thing is, I'm having some problems when it comes to encode the audio, for some reason I'm trying to understand why the generated video is broken, it seems the audio has not been written

Wrapping std::vector of boost::shared_ptr in SWIG for Python

谁说胖子不能爱 提交于 2019-12-05 05:27:59
问题 EDIT: Solved, my mistake; explained in my answer. I have this: std::vector < boost::shared_ptr < Entity > > entities; and I try to expose it through SWIG like this: %include "boost_shared_ptr.i" %include "std_vector.i" %shared_ptr(Entity) %include <Entity.h> namespace std { %template(EntityVector) vector<boost::shared_ptr<Entity> >; }; %include <TheFileWithEntities.h> However, in Python entities ends up being a tuple: import MyModule print type(MyModule.cvar.entities) # Output: (type 'tuple')

SWIG 3 中文手册——1. 前言

旧街凉风 提交于 2019-12-05 05:16:19
目录 1 前言 1.1 引言 1.2 SWIG 版本 1.3 SWIG 许可证 1.4 SWIG 资源 1.5 前提要求 1.6 本手册的组织构成 1.7 如何避免阅读手册 1.8 向后兼容 1.9 发行说明 1.10 捐赠 1.11 错误报告 1.12 安装 1.12.1 Windows 安装 1.12.2 Unix 安装 1.12.3 Macintosh OS X 安装 1.12.4 测试 1.12.5 示例 1 前言 1.1 引言 SWIG (Simplified Wrapper and Interface Generator) is a software development tool for building scripting language interfaces to C and C++ programs. Originally developed in 1995, SWIG was first used by scientists in the Theoretical Physics Division at Los Alamos National Laboratory for building user interfaces to simulation codes running on the Connection Machine 5 supercomputer

Installing pocketsphinx python module: command 'swig.exe' failed

匆匆过客 提交于 2019-12-05 04:41:58
I'm getting something like this. Can anyone please tell me how to fix this. C:\Users\krush\Documents\ML using Python>pip install pocketsphinx Collecting pocketsphinx Using cached pocketsphinx-0.1.3.zip Building wheels for collected packages: pocketsphinx Running setup.py bdist_wheel for pocketsphinx: started Running setup.py bdist_wheel for pocketsphinx: finished with status 'error' Complete output from command C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\krush\\AppData\\Local\\Temp\\pip-build-cns2i_wb\\pocketsphinx\\setup.py';f=getattr(tokenize,