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
0 answers

Connecting Python server to back-end C++

Summary: I have a server using BottlePy that hosts a web-interface for the app I'm working on. The back-end was written in C++ because the original front-end was written using GTK+3. Since it was written using GTK+3, the front-end has a lot of…
Alex Eastman
  • 305
  • 1
  • 10
1
vote
0 answers

Pass shared_ptr as argument with SWIG

I have a function implemented in func.hpp by C++ as void func(const std::vector > &x) { //something is doing here. } and in the swig .i file, I have added %include %include…
maomiT
  • 11
  • 1
1
vote
2 answers

Python SWIG wrapper for C++ rvalue std::string &&

I'm trying to build a python wrapper for gnucash c++ parts. In QofBackend I encountered the method const std::string && get_message (). In python this message returns instead of a string as in…
c.holtermann
  • 113
  • 1
  • 9
1
vote
1 answer

Cant get swig %ignore to ignore class in namespace resulting in compile error

I have a class declared in a header that's giving compile errors when run through swig: namespace nsA { namespace nsB { #define DISABLE_COPYING_AND_ASSIGNING(ClassName) ClassName(const ClassName&) = delete; \ ClassName& operator=(const…
Geordie
  • 1,920
  • 2
  • 24
  • 34
1
vote
0 answers

Swig python wrapper not loading/linking symbols

I'm attempting to wrap a library that's made available as a dylib with development headers into python for use with an existing application. I've created my .i file, which compiles without issue, however when I attempt to link the ndipy_wrap.o and…
1
vote
1 answer

python, is swig recommended?

I was reading that in python we can use swig to convert a program from c language to python and I have some questions regarding that a. does that work for every code in c or only for most cases? if yes, then why don't most companies make a version…
user13514298
1
vote
0 answers

Memory Violation when calling DLL function from c#

I have created dll using swig from LibrDWG. When I try to call one of the functions: var layers= LibreDWG.dwg_get_layers(dwg_Data); I got memory violation exeption: Exception thrown at 0x00000000622A995F (LibreDWG.dll) in LibreDWG_WPF.exe:…
1
vote
1 answer

How to configure swig to map size_t as ulong instead of uint (c#) in 64 bit platforms

The problem is that swig is mapping size_t variables as uint in c# this is correct in 32 bit, but I need to create the wrapper for the 64 bit version too. I need help with the configuration of the interface to use ulong instead of uint for size_t on…
Agustin Cautin
  • 411
  • 5
  • 23
1
vote
1 answer

Simple SWIG with C++ for python compiles but the output does not seem to be correct?

I am fairly new to SWIG (and c++), so I was trying to use an example from this website It seems like a simple code. I compiled it...successfully (I think?) on Visual Studio. 1>------ Rebuild All started: Project: minimal, Configuration: Release…
kwangsk
  • 36
  • 4
1
vote
1 answer

How to avoid SWIG's "Deprecated command line option: -modern. This option is now always on."

Since I'm running an updated system, my build logs (in this case, GNU Radio) are cluttered with Deprecated command line option: -modern. This option is now always on. I've boiled that down to SWIG as culprit. However (as usual), the SWIG…
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
1
vote
1 answer

passing pyqt object to swig exported c++ code

anyone knows if there exists a method for passing pyQt objects to c++ code? I'll explain better; say i have this c++ code void QtGuiPDLVisitor::set_layout(QLayout* _layout){ layout = _layout; } where QtGuiPDLVisitor is a c++ class…
Luca Piccinelli
  • 379
  • 1
  • 17
1
vote
1 answer

Swig, Python, C++: TypeError: in method 'Geodatabase_Open', argument 2 of type 'std::string'

I am new to C++ and SWIG. This is my first project. I am able to successfully build my Python extension using distutils. However, when I try my object, I keep getting this error. It seems that there is a conversion problem from getting the python…
Hugo Estrada
  • 607
  • 1
  • 8
  • 18
1
vote
0 answers

how to create a swig custom typemap for std::set to be wrapped by native python set?

The default typemap provided by swig expects a python list as input for constructing a set instead of native Python set (see here). Indeed, %include "std_set.i" %template(IntSet) std::set; will trigger the following behavior in python: >>>…
Eurydice
  • 8,001
  • 4
  • 24
  • 37
1
vote
1 answer

why swig casts python list to std::vector seamlessly and not std::set?

I make some trials with swig in order to extend basic C++ class to python. I found a behavior related to the use of sets that I can't explain so far. Here are my scripts: MyClass.h: #pragma once #include #include class…
Eurydice
  • 8,001
  • 4
  • 24
  • 37
1
vote
1 answer

SWIG convert C-Pointer stringvalue to tcl string

because of my limited knowledge in C and SWIG i couldn't manage to adopt any public example for converting c-pointer chars to tcl strings .... I always get stuck at the problem that my tcl variable just doesn't get dereferenced like this : tcl_str…