swig

Using custom Qt subclasses in Python

First off: I'm new to both Qt and SWIG. Currently reading documentation for both of these, but this is a time consuming task, so I'm looking for some spoilers. It's good to know up-front whether something just won't work. I'm attempting to formulate a modular architecture for some in-house software. The core components are in C++ and e...

creating PHP C/C++ extension modules using SWIG

I have written some C/C++ extension modules for PHP, using the 'old fashioned way' - i.e. by using the manual way (as described by Sarah Golemon in her book). This is too fiddly for me, and since I am lazy, and would like to automate as much as possible. Also, I have used SWIG now to generate extensions to Python, and I am getting to li...

How do you redirect a standard stream of a C++ routine wrapped with SWIG and exposed to Python?

Is it possible to control the standard streams of C++ code in python? The code is wrapped with SWIG and then exposed to Python where I call one of its functions. I am getting all kinds of unwanted messages coming from C++ code and I want to suppress them either by not using the output stream or by redirecting it to a bit bucket, e.g. de...

c++-to-python swig caused memory leak! Related to Py_BuildValue and SWIG_NewPointerObj

Hey gurus, I have the following Swig code that caused memory leak. PyObject* FindBestMatch(const Bar& fp) { Foo* ptr(new Foo()); float match; // call a function to fill the foo pointer return Py_BuildValue( "(fO)", match, SWIG_NewPointerObj(ptr, SWIGTYPE_p_Foo, ...

How to integrate C++ function that can throw the MyException in swig interface file

Hi, I am new to swig,using swig for integrating c++ code to Perl,I have c++ function like void s() throw MyException. How i can integrate the c++ function that can throw the MyException in the swig interface file.How i can called the c++ function in Perl. Any Help in this regard is highly appreciated. ...

How do I make C++/wxWidgets code accessible to a wxPython app?

I have a code library which is written in C++ and makes extensive use of the wxWidgets library. I'm now trying to wrap my library (currently using SWIG) so that it's callable from wxPython, but I've hit a wall: ------ Build started: Project: MyLibLib, Configuration: Release_SWIG_OutputForBin Win32 ------ Performing Custom Build Step In ...

swig jni problem

Hello I am trying to use swig tool for my ".c" files. i run the following commands , $swig -java example.i $gcc -c example.c example_wrap.c -I/c/jdk1.3.1/include -I/c/jdk1.3.1/include/win32 Then i got the following error. example_wrap.c:135:17: error: jni.h: No such file or directory example_wrap.c:159: error: expected ‘)’ before...

C++ Swig Python (Embedded Python in C++) works in Release but not in Debug

Platform: Windows 7, 64 bit (x64), Visual Studio 2008 I chose Python & Swig binding as the scripting environment of the application. As a prototype, created a simple VS solution with main() which initializes Python (Py_Initalize, Py_setPyHome, etc) & executes test.py. In the same solution created another project which is a DLL of a si...

How to expose a function in an exe to Python using SWIG without creating a dll (.pyd)?

I got a prototype working of exposing C++ classes & methods to python using SWIG. I had to create a DLL (.pyd) of the classes/members I want to expose (_MyModule.pyd & MyModule.py). But now I want to expose classes/members/functions in the exe. How to do this? Refactoring the exe is not an option. One way is to create a wrapper dll fo...

Problems replacing a Python extension module while Python script is executing

I'm trying to solve the following problem: Say I have a Python script (let's call it Test.py) which uses a C++ extension module (made via SWIG, let's call the module "Example"). I have Test.py, Example.py, and _Example.so in the same directory. Now, in the middle of running Test.py, I want to make a change to my Example module, recomp...

Compiling C-dll for Python OR SWIG-module creation, how to continue ??

I reference this file "kbdext.c" and its headerfile listed on http://www.docdroppers.org/wiki/index.php?title=Writing_Keyloggers (the listings are at the bottom). I've been trying to compile this into a dll for use in Python or Visual Basic, but have not succeeded. I'm not familiar with C or GCC to sort out the problems or do the dll co...

Syntax error in SWIG using __thread keyword

I am trying to make some code thread safe for use with pthreads. This code is written in C++, but is linked to using SWIG. g++ compiles this correctly, but when swig tries to create a wrapper, I get: fast_alloc.hh:109: Error: Syntax error in input(3) The original, unsafe code that compiles correctly is: static void *freeLists[N...

What is SWIG and for what it is used for

I just on internet the Google is using swig. Does any one have used that and tell me will it be helpful for me. I mean why it is used and how it can make my work good. As google is using it must be good ...

How to install SWIG on Linux centos

I want to install SWIG on My linux server to test some stuff. How can install that ...

Compiling a library for Ruby with SWIG on Mac OS X

I tried to compile the following library and everything went smooth until the last step. /* File : computation.c */ int add(int x, int y) { return x + y; } /* File: computation.i */ %module computation extern int add(int x, int y); $ swig -ruby computation.i $ gcc -c computation.c $ gcc -c computation_wrap.c -I/opt/local/lib/ruby/1....

How to use float ** in Python with Swig?

Hi there, I am writing swig bindings for some c functions. One of these functions takes a float*. I am already using cpointer.i for the normal pointers and looked into carrays.i, but I did not find a way to declare a float*. What do you recommend? interface file: extern int read_data(const char *file,int *n_,int *m_,float **data_...

How to use float ** from C in Python?

Hi, after having no success with my question on How to use float ** in Python with Swig?, I started thinking that swig might not be the weapon of choice. I need bindings for some c functions. One of these functions takes a float**. What would you recomend? Ctypes? Interface file: extern int read_data(const char *file,int *n_,int *m_,f...

SWIG support for inheritance of static member functions

SWIG doesn't wrap inherited static functions of derived classes. How it can be resolved? Here is a simple illustration of the problem. This is a simple C++ header file: // file test.hpp #include <iostream> class B { public: static void stat() { std::cerr << "=== calling static function B::stat" << std::endl; } void nonstat() c...

Best approach for creating a SWIG API to a library that writes to stdout?

Hi all, I maintain a set of C++ tools (bedtools) that are used in the genomics/bioinformatics field. Several users have asked that I create APIs to the libraries such that "hooks" are available for Perl and Python, for example (many requests for Python). Therefore, I am interested in using SWIG, as it has support for C++ and in theo...

How to call Java from C++ using SWIG?

I am able to call C++ code from Java using SWIG but I can't find any documentation on how to do the reverse (call Java from C++). The official SWIG documentation says (http://www.swig.org/Doc1.3/Java.html#java_overview): "SWIG enables a Java program to easily call into C/C++ code from Java. Historically, SWIG was not able to generate a...