Questions tagged [swig]

SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl.

SWIG is typically used to parse C/C++ interfaces and generate the 'glue code' required for the target language to call into the C/C++ code. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. SWIG is free software and the code that SWIG generates is compatible with both commercial and non-commercial projects.

For information about the features of SWIG and the supported languages see: http://www.swig.org/compare.html

One of many projects using SWIG to generate libraries for the above languages is Subversion. Other projects listed here.

Documentation:

3063 questions
1
vote
1 answer

How to use Mat_ template in swig?

So I have an .hpp file that I'm planning to use in swig, but said file has a template (Mat_ to be exact), but whenever I run swig I end up getting: example.hpp::30: Error: Syntax error in input(1). With line 30 being: Mat_
SSBakh
  • 1,487
  • 1
  • 14
  • 27
1
vote
2 answers

How can I wrap a variadic template member function of a variadic template class in SWIG?

I have a header file containing the definition of a variadic template, which also contains a few variadic templated member functions. Code snippets below have been significantly simplified and cut down for brevity: #pragma once template
Pesho_T
  • 814
  • 1
  • 6
  • 18
1
vote
1 answer

SwigPyObject and JSON communication inside python code

Intro. I have a C++ application, I use SWIG to launch GetObjects and PutObjects methods which are defined in python code. GetObjects method opens JSON formated file, takes objects from there and returns back them to C++ application. While the…
Sophie Sperner
  • 4,428
  • 8
  • 35
  • 55
1
vote
1 answer

Create a copy class method for a Python object containing a Swig object

I have created a Python class with an attribute that is a Swig object (which happens to be a wrapper of a C structure). I want to be able to create copies of that class, e.g., by defining a __copy__ method, that contain independent copies of the…
Matt Pitkin
  • 3,989
  • 1
  • 18
  • 32
1
vote
0 answers

How do I get this SWIG-generated shared library that my SWIG-generated library depends on into the search for dlsym?

I'm using Ubuntu 16.04, g++ 5.4.0, and CMake 3.5.1, but my results are consistent on macOS Mojave with the most recent XCode version. I have one program with a SWIG module, MyModule, that depends on a system that is a bunch of C++ libraries and its…
Michael Iatauro
  • 133
  • 1
  • 4
1
vote
1 answer

Build error while creating wrapper for C++ to javascript using swig

I am building a c++ wrapper to javascript in swig. Created example.i file compiled and created example_wrap.cxx file, then while compiling with node-gyp it gives build error. Error : make: Entering directory…
user11758292
1
vote
1 answer

Unknown CMake command 'swig_add_module'

I'm trying to run code with armanpy but it fails to compile with the error Unknown CMake command 'swig_add_module', the log file doesn't specify any errors only the cmd does. I've tried installing swig, changing the CMakeLists.txt file all without…
DisplayName
  • 89
  • 1
  • 2
  • 12
1
vote
1 answer

Garbage collection and custom getter in SWIG

I'm not the author, but there's a public software package I use that seems to be leaking memory (Github issue). I'm trying to figure out how to patch it to make it work correctly. To narrow the problem down, there's a struct, call it xxx_t. First…
polm23
  • 14,456
  • 7
  • 35
  • 59
1
vote
0 answers

SWIG wrappers and deleted default constructors

I am trying to build a Go SWIG wrapper for E57Format, the C++ library for E57 files (see https://github.com/asmaloney/libE57Format). Go can't compile the wrapper because it needs default constructors for some classes in which the default constructor…
1
vote
0 answers

How to write setup.py to produce generic .whl package

I am writing setup.py for my small python package, which is python wrapper on c++ tool, and it's depends on shared libraries like icu-uc, boost_program_options, and some custom ones. Python wrapper build with swig. I use Extension(libraries=[...])…
Dima Zhylko
  • 65
  • 2
  • 8
1
vote
0 answers

defining map > return type gives random values on every run

After building and calling it using python main.py it gives me result like this: [array([22209328, 21870, 0], dtype=int32), array([24088960, 21870, 1], dtype=int32)] Why is it happening? I can't find out the bug in my code. I…
ninjakx
  • 35
  • 13
1
vote
0 answers

How to wrap map containing int and vector of int in swig?

I want to return a hashmap from C++ to Python using Swig. I am able to print the keys but not able to fetch values. It is giving me this output: {0: > *' at 0x7fa646cdfcf0>, 1:
ninjakx
  • 35
  • 13
1
vote
1 answer

How to return `uint []` from `unsigned int *` using swig

I have to wrap the following c++ function: class Foo { unsigned int *getVector3(); }; The member function getVector3, returns a (fixed) 3D array, eg [1,2,3]. How should I use arrays_csharp.i for a return type ? The documentation only describes…
malat
  • 12,152
  • 13
  • 89
  • 158
1
vote
2 answers

How to import ostringstream using ctypes in python3?

I am writing analyser for natural language and I have a wrapper of c++ code in python 3 created with swig. I'd like to use a function which is some kind of stream writer and it takes std::ostream & os as the parameter. So I guess it would work if I…
Dima Zhylko
  • 65
  • 2
  • 8
1
vote
1 answer

ImportError: undefined symbol when importing swigged c++-class in python

I try to use a c++-class for socket communication in Python. Therefore, I created a class that uses nngpp. When importing the swigged file to python, I get the ImportError: undefined symbol: nng_msg_insert. The definition of the class is: /*…
ltcmdtuvok
  • 33
  • 5