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 can I tell SWIG to copy my source's documentation into it's generated files?

I have some C API that contains docs such as // file: my_module.h /** * My function. * @param x A number. * @return Return. */ extern int my_function(int x); My swig file %module my_module %{ #include "my_module.h" %} %include…
aganm
  • 1,245
  • 1
  • 11
  • 30
1
vote
0 answers

Using Swig, how do I convert a const uint64_t * to a ruby array?

I am using Swig to wrap a c library for use with Ruby. There are several functions that return an array of of uint32_t and uint64_t as pointers. For example something like: const uint64_t *foo(); const uint32_t *bar(); I feel I should be able to…
nPn
  • 16,254
  • 9
  • 35
  • 58
1
vote
0 answers

How do you use setuptools to build a Python package containing runtime libraries?

Background: I've used SWIG to develop a Python wrapper for a C/C++ library. Now I need to use setuptools to package the project for distribution. The package needs to include the SWIG generated C extension and all DLL dependencies. My project…
rgmann
  • 31
  • 2
1
vote
0 answers

How to add a hand-written CPython method to my SWIG wrapped class

I have a C++ class that is wrapped for Python using SWIG -builtin. I'd like to add a method to that class that is wrapped in pure CPython, e.g., I want this in my methoddef list: { "handRolledCall", (PyCFunction) _wrap_MyClass_handRolledCall,…
dbn
  • 13,144
  • 3
  • 60
  • 86
1
vote
1 answer

Wrapping C++ modules in Java

I've inherited a project, originally written in C++. Due to implementation requirements, I need to either re-write the project in a JVM based language, like Java or Kotlin, or simply wrap the existing code in a Java or Kotlin (RESTful) API. The…
Iggydv
  • 166
  • 2
  • 12
1
vote
1 answer

How to generate multiple wrappers for a single C function?

I have a C function like so. void useData(char* buf) { // TODO..... } With swig I've managed to get this generated. public static void useData(SWIGTYPE_p_char buf) { // SWIG stuff.... } Now this worked but sometimes I want to pass a…
Dominic Fischer
  • 1,695
  • 10
  • 14
1
vote
0 answers

Python wrapper of a C++ program that takes command line arguments

I have created a Python wrapper around a C++ program using SWIG on Linux. The structure of the main function of the C++ program is like this: MyProg.cpp int main (int argc, char *argv[]) { ... ... ... } In other words, it takes a number…
1
vote
1 answer

SWIG generated Python function annotations do not work

I recently started using swig to wrap one of my C++ libraries. I want to use this code in Python and it is working good so far. The Problem is that Python does not know what objects the wrapped functions return. Of course I can still call methods on…
sunfl0w
  • 11
  • 3
1
vote
1 answer

Python wrapper around C++ using SWIG. Argument type not recognised

I am trying to build a Python wrapper around a C++ code using SWIG on Linux and I am not sure if the wrapper is being created correctly. As an example, here is a mini-problem (within my larger project). Suppose I have a file called…
1
vote
1 answer

Custom destructors in SWIG for opaque structures

I'm unable to work out how to get SWIG to have a custom destructor for an opaque data type that is managed by the library I'm wrapping. struct Foo; Foo* NewFoo(); void UpdateFoo(Foo*); void DestroyFoo(Foo*); I've attempted to wrap this in SWIG…
Free Wildebeest
  • 7,272
  • 8
  • 38
  • 42
1
vote
0 answers

Is there a way to rebuild Python Subversion bindings on Linux?

I'm running Trac on a CentOS 5 host and it was running horribly slow. I tried installing Python 2.6 from the EPEL (plus mod_wsgi) and it is more responsive but I now get: Can't synchronize with repository "(default)" (Unsupported version control…
IBBoard
  • 909
  • 4
  • 16
1
vote
1 answer

Problem wrapping a C++ class with a mutex in a member, using Swig

I have a C++ class containing a (Poco) mutex: class ClassWithMutex { public: ClassWithMutex(); virtual ~ClassWithMutex(); Poco::Mutex mMyMutex; private: …
Totte Karlsson
  • 1,261
  • 1
  • 20
  • 55
1
vote
0 answers

How to solve the warning "Warning 401: Nothing known about base class 'xxxx' Ignored." in swig

I am trying to use swig to call c++ functions from python. Its actually working (I can import the module in python), but there are some warnings that i want to solve before i get in trouble later. I tried to just include the code, that produces the…
hkn27
  • 51
  • 5
1
vote
1 answer

Using SWIG to build Python Module using 3rd-Party Drivers

I'm using a 3rd-Party Vendor who is providing a Windows Driver (DLL) and C Header Files. What I'm trying to do is use SWIG to recompile the header file into a Python Module. Here are the my files: - BTICard.i - BTICard.h - BTICARD64.dll -…
WeSC
  • 11
  • 3
1
vote
0 answers

Python module by SWIG in conda: Where do I have to place which file?

I am trying to generate Python bindings for a C++ shared library with SWIG and distribute the project with conda. The build process seems to work as I can execute import mymodule as m ret = m.myfunctioninmymodule() in my build directory. Now I want…
carlosvalderrama
  • 465
  • 1
  • 6
  • 22