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 tell Cloud ML engine to install SWIG?

I'm facing a RL problem which uses Box2D package and I want to do some computations using Google's AI platform. I made a setup.py file: from setuptools import find_packages from setuptools import setup REQUIRED_PACKAGES = ['gym>=0.11.0',…
1
vote
0 answers

Compile PHP extension using SWIG

I am trying to compile the swig interface of crfsuite as a PHP module. So far I've managed to actually compile a crfsuite.so file, load it as an extension in PHP and call methods on it. As far as I can see any method call that was wrapped by SWIG…
ferdynator
  • 6,245
  • 3
  • 27
  • 56
1
vote
2 answers

How can I use the Google page-speed SDK from C#

I would like to be able to use the Google page-speed SDK ( http://code.google.com/p/page-speed/ ) from within managed code ( C# ) I am a bit out of my depth, so if anyone can explain what I need to do that would be great. I have come across…
Chris
  • 41
  • 6
1
vote
0 answers

Python binding to sysrepo gives invalid argument exception

I'm trying to bind some existing Python 2 code with the sysrepo package in OpenWrt. The Python binding uses SWIG to interface with the underlying C/C++. I try to create a YANG object by calling the Session.set_item() function, but I get an…
NetHead
  • 71
  • 1
  • 10
1
vote
1 answer

SWIG typemap to return an output param char*/size_t

I have an C API that uses output params for strings. (The real signature has been changed to protect the innocent. This is a simplistic example.) void func( char* buf, size_t buflen, char* buf2, size_t buf2len ); buf and buflen are effectively…
mojo
  • 4,050
  • 17
  • 24
1
vote
1 answer

How can I fix "SystemError: null argument to internal routine" error when python callback in called from C

Intro I'm writing a python application which uses a library written in C. When some event occurred at C level a Python callback is used to be called. Here is a part of my python callback definition: def callback(str1, str2, cdata, flag): …
Nick
  • 133
  • 1
  • 10
1
vote
1 answer

If I use swig do I have to build multiple .so/.dll linked aginst every version of python I would like to support?

I have a C/C++ project in which I am using swig to interface with python. I would like to know if I have to build against every version of python lib to have my script be supported or is there a simpler way. I understand that I can use distutils to…
ZNackasha
  • 755
  • 2
  • 9
  • 29
1
vote
0 answers

Swig c++ to lua custom type constructor recognises string as double

I'm trying to return my C++ struct to lua using Swig and I want to have two constructors taking string or double as arguments. struct MyType { MyType(const std::string & arg) { std::cout << "string constructor\n"; } …
Mahashi
  • 119
  • 7
1
vote
1 answer

Understanding Swig generated Python file

In the course of some work I am currently involved in I needed to understand better the content of the .py file which is generated when wrapping C++ using Swig. This is in the context of an existing system (which I did not write) which adds some…
Bob
  • 195
  • 1
  • 11
1
vote
2 answers

SWIG INOUT types (C++ to Python)

I'm creating a python wrapper for a C++ api, making support for some types was more or less straightfoward using templates but the api needs some variables by reference, one of them is an int and the other is float. If I am not wrong it is done by…
Frank Escobar
  • 368
  • 4
  • 20
1
vote
1 answer

Swig exception in Python director class

I'm wrapping some classes using Swig directors in Python. Each of my class methods returns a MyError class. What happens is, once I derive a python class from one of my C++ and I forget to return the MyError() object but I return None of "pass" or I…
Leonardo Bernardini
  • 1,076
  • 13
  • 23
1
vote
1 answer

SWIG C++/Python binding and support of conditional members with std::enable_if

Sorry for the long title, here is what I'm trying to achieve: I have a small C++ class with a bool template parameter which, when true, disables its setter methods using std::enable_if. Here is a simplified example: template< bool IS_CONST > class…
Citron
  • 1,019
  • 9
  • 24
1
vote
1 answer

Object's address, passed from Lua to C++, is returning me the wrong value in a member variable

I'm currently trying some experiences with the SWIG tool for wrapping generation of C++ and Lua code. After some fighting with SWIG (trying to set it up, learn how it works, etc...), I finally got a working example. However, I've come up with an…
Canella
  • 444
  • 4
  • 15
1
vote
2 answers

How to force swig to generate the appropriate list of arguments in the help page of a module?

The help page of a module generated with SWIG is not quite helpful. In fact, it doesn't even list the arguments of each function. Help on module example: NAME example FILE /home/anon/example.py DESCRIPTION # This file was…
Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40
1
vote
1 answer

Can't build a go module built with Swig due to missing include path

In my swig interface file I use includes such as: %{ #include "lib-cpp/types/lists/linked-list.hpp" %} %include "lib-cpp/types/lists/linked-list.hpp" However when I run go install I get: navdb_go_client_wrap.cxx:258:14: fatal error:…
Jason
  • 531
  • 6
  • 19