swig

Running a SWIG bound Python+C program gives a missing DLL error when running on another computer

做~自己de王妃 提交于 2019-12-23 17:15:10
问题 So I have compiled a small testing program that uses SWIG as a bridge between python and C. The main part of the program is the python file. The thing runs fine on my own pc, but as soon as I transfer it to another, it immediately throws a "ImportError: DLL load failed: The specified module could not be found." error. I tried to see if it could be a file location that was statically coded by moving it to another directory on my own pc, which still worked fine. Next I did some debugging in the

How do I process string arrays with swig and C#?

只愿长相守 提交于 2019-12-23 15:27:38
问题 My C++ class has a method called init : int init(int argc, char **argv) Also, I have a callback: void callback(int num, char **str) My problem is that Swig generates a strange class SWIGTYPE_p_p_char.cs , and no string[] as I expected. Please, advice. 回答1: SWIG has some typemaps for passing arrays to functions, in arrays_csharp.i. There isn't one for char *INPUT[] however but we can adapt the typemaps to do what you want: %module test %include <arrays_csharp.i> CSHARP_ARRAYS(char *, string)

Crash when calling into C++ library from Perl using SWIG (AIX 5.1)

不羁的心 提交于 2019-12-23 12:33:58
问题 I'm trying to call into a C++ library from Perl on an AIX 5.1 machine. I've created a very simple test project to try to exercise this. My C++ shared library ( test.cpp ): #include <stdio.h> #include <iostream> void myfunc() { printf("in myfunc()\n"); std::cout << "in myfunc() also" << std::endl; } My SWIG interface file ( test.i ): %module test %{ void myfunc(); %} void myfunc(); I then build the shared object like so: swig -c++ -perl test.i g++ -c test_wrap.cxx -I/usr/opt/perl5/lib/5.6.0

Swig - generate wrapper to pass an array of struct

*爱你&永不变心* 提交于 2019-12-23 12:14:22
问题 Update I have just found out about the %apply directive (see here for instance). Unfortunately I can't make it work with structs: %module packer_cs %include "carrays.i" %{ #include "packer.h" %} %include "typemaps.i" %include "arrays_csharp.i" %apply image_t INPUT[] { image_t *images } %include "packer.h" This results in: swig -csharp -outdir bin\csharp packer\packer.i Warning 453: Can't apply (image_t INPUT[]). No typemaps are defined. I can't find any documentation whatsoever about this

Python can't install Box2D swig.exe failed with error code 1

南笙酒味 提交于 2019-12-23 10:56:36
问题 I try to install Box2D on python but I get the error log: C:\>pip3 install Box2D Collecting Box2D Using cached https://files.pythonhosted.org/packages/cc/7b/ddb96fea1fa5b24f8929714ef483f64c33e9649e7aae066e5f5023ea426a/Box2D-2.3.2.tar.gz Building wheels for collected packages: Box2D Running setup.py bdist_wheel for Box2D ... error Complete output from command c:\users\hp-laptop\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\HP-LAP~1\

Is ignoring __attribute__((packed)) always safe in SWIG interfaces?

非 Y 不嫁゛ 提交于 2019-12-23 09:39:31
问题 Since SWIG can't parse the __attribute__((packed)) on some C structs I'd like to wrap, I work around this by putting a #define __attribute__(x) in my .i file. When will this come and bite me? 回答1: This is actually perfectly sane. SWIG doesn't need to know anything about the layout of the struct s you're wrapping in order to be able to generate correct code. (It doesn't even need to know about all the members they contain even). The reason for this is that the code which is generated is

Swig / Python memory leak detected

痞子三分冷 提交于 2019-12-23 06:58:07
问题 I have a very complicated class for which I'm attempting to make Python wrappers in SWIG. When I create an instance of the item in Python, however, I'm unable to initialize certain data members without receiving the message: >>> myVar = myModule.myDataType() swig/python detected a memory leak of type 'MyDataType *', no destructor found. Does anyone know what I need to do to address this? Is there a flag I could be using to generate destructors? 回答1: SWIG always generates destructor wrappers

SWIG - C# Calling from UWP Background Task or Extended Execution

那年仲夏 提交于 2019-12-23 04:43:47
问题 I wonder if anyone has tried calling a swig C# wrapper around a C++ library from a UWP Background Task, Extended Execution, or Activation Trigger? My C# swig wrapper provides functionality written in C++ which handles network calls to services such as cloud etc. It might download or upload files such as documents, images, etc or it might just synchronize them with local on machine copies. I have been doing lots of reading/research lately on the topic of Background Activation and Foreground

Sphinx and documenting python from a swigged C++ api [duplicate]

China☆狼群 提交于 2019-12-23 04:03:25
问题 This question already has answers here : Is there a good way to produce documentation for swig interfaces? (2 answers) Closed last year . I'm basically asking the same question as this: Is there a good way to produce documentation for swig interfaces? However, that one was like two years old and now there is sphinx. Question is, can sphinx automatically get something out from the python code that swig produces, or does one need to manually 're-enter' the documentation that is in the C++ code?

How can I collapse multiple arguments into one SWIG parameter

浪尽此生 提交于 2019-12-23 03:45:26
问题 I'm trying to write a typemap that converts multiple/variable arguments into one input parameter. For example, say I have a function that takes a vector. void foo(vector<int> x); And I want to call it like this (happens to be in Perl) foo(1,2,3,4); The typemap should take arguments ($argnum, ...), gather them into one vector and then pass that to foo. I have this so far: typedef vector<int> vectori; %typemap(in) (vectori) { for (int i=$argnum-1; i<items; i++) { $1->push_back( <argv i> ); //