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

Pytss: passing arguments to fapi_Sign() method - invalid argument type (Fapi_Sign argument 4 of type uint8_t const *)

As this is my first question here, I'd like to say hello to all community. I always preferred to do it the hard way, although this time I spent several hours searching, trying and nothing points any closer to the solution. So. I have assignment to…
Mr. 0xCa7
  • 100
  • 7
1
vote
1 answer

Fatal Error: 'jni.h' file not found on Mac OSX 10.15.7

I've tried to run an old java program with some libraries in C. While running make command,I kept encounter this error which I believe is related to JAVA_HOME setting swig/main_6_comp_wrap.c:154:10: fatal error: jni.h: No such file or…
EEEEEric
  • 77
  • 3
  • 9
1
vote
0 answers

Python's 'setuptools' doesn't include auto-generated SWIG Python files

Background Due to performance reasons in my Python application, I will eventually be trying to write a couple of functions in the C language to convert integers to/from a VLQ binary string representation. Since I don't want to deal with…
Mr. Minty Fresh
  • 229
  • 1
  • 6
1
vote
1 answer

Swig c++/c# keep getting "Type Initialized Exception"

I am currently creating my first swig project. I have some c++ code, where i am using 1 of the classes functions in my c# UI. I have created a .i file that looks something like this: %module mymodule %{ #include…
user812352
  • 83
  • 7
1
vote
1 answer

numpy array with swig mapping

I have function which contains 3, one dimension array arguments and one length argument. for example: float my_func(int *arr1, int *arr2, int *arr3, int length) This array would be IN_ARRAY and needed to write swig wrapping for it so from the…
zero cool3
  • 59
  • 5
1
vote
0 answers

Swig — how to add a simple via-get-function attribute?

I have a simple C structures that I want to make visible in Python interpreter: struct OpenFile { int modified; const char *filename; }; typedef struct OpenFile OpenFile; struct OpenFiles { OpenFile *open_files; int…
psprint
  • 349
  • 1
  • 10
1
vote
0 answers

SWIG generated code leaks memory when returning early

Given the following script: %typemap(in,noblock=1) int * { $1 = malloc(sizeof(int)); if($1 == NULL) { return $null; } } %typemap(freearg,noblock=1) int * { free($1); } void afunc(int *varA, int *varB); For Java, SWIG…
Nick
  • 3,958
  • 4
  • 32
  • 47
1
vote
1 answer

jni callback works for java types, but not c types

I have followed the advice at registering java function as a callback in C function and can callback with "simple" types such as integer and string, e.g.: jstring js = (*env)->NewStringUTF(env, "hello"); (*env)->CallStaticVoidMethod(env, cls,…
mab
  • 431
  • 1
  • 5
  • 15
1
vote
1 answer

How to use PocketSphinx in .NetCore C# running on Raspberry PI?

I am trying to come up with a version of the pocketsphinx wrapper library which would work on a Raspberry PI running in a .NetCore C# app. I know that the official Github repo of PocketSphinx suggests SWIG as the best way to port the library in…
bre_dev
  • 562
  • 3
  • 21
1
vote
2 answers

How to initialize C struct members at creation in SWIG for Python?

Let's say we have a following struct in C: typedef struct buffer { uint8_t* const data; const size_t maxSize; size_t size; } buffer_t; How can I make a SWIG wrapper for this so that when buffer_t is created in Python it allocates given…
JuhoL
  • 53
  • 5
1
vote
1 answer

Building CXX object CMakeFiles error : ProductCategory *result = 0 ; was not declared in the scope (SaleItem has Product Category Pointer as member )

I have a SaleItem class that has a pointer of an another class Product Category as member function, the getter of the SaleItem class that returns the pointer to the ProductCategory is causing the error. The IDE does not give the error straightaway…
rrajanuk
  • 27
  • 8
1
vote
1 answer

SWIG error: Syntax Error in input(1)

I'm getting the Syntax Error in input(1) error for this line of code, in C when I do: swig -python myfile.i in console. It concerns the following code, specifically the last line of these typedefs. typedef unsigned short WORD; typedef unsigned…
limenuke
  • 53
  • 2
  • 7
1
vote
1 answer

SWIG (Java): How do I pass a struct with callback functions to C++ from an Android application?

I am developing a real-time communication app (video and audio) for Android using a WebRTC-based C++ code library. I generate a JNI bridge using SWIG to access the native code from Java. The behaviour of the call is determined via a number of…
1
vote
1 answer

Swig C++ with multiple includes to Python module

I need to export some C++ code to Python modules. I have the following code: #include #include #include #include "1.h" #include "2.h" #include "3.h" #include "4.h" #include "5.h" #include "6.h" using namespace…
Codearts
  • 2,816
  • 6
  • 32
  • 54
1
vote
1 answer

SWIG error: was declared 'extern' and later 'static'

I'm using swig to produce a python C++ interface such that I can make scripts in python to call my c++ functions. I've gotten as far as: swig -c++ python filename.i gcc -c filename.cpp filename_wrap.cxx -shared -Ic:\includepath Where the include…
limenuke
  • 53
  • 2
  • 7