FAQ Database Discussion Community


error in inheritance c++ using swig

python,c++,swig
i have a have a c++ code that is been wrapped by swig and used by python. i want to create a way to run a callback python code inside the c++ code. so i'v created a "abstract" class (it's not abstract yet) and i'm sublassing it in c++ inside...

Return an array of java objects using SWIG

java,c++,swig
I am writing a JNI wrapper for a C++ library using SWIG. One of the methods in a library returns an array of structs in an allocated memory: typedef struct { int id; double x; double y; } DataStruct; int get_all_data ( long ref, DataStruct **ppdata, size_t *psize ) {...

Passing reference from Python to c++ function wrapped with swig for return value

c++,python-3.x,pass-by-reference,swig
Disclaimer, I am a swig and python noob I have my own c++ library and I am wrapping it to use in python with swig. My c++ class is like this: public MyCppClass() { public: void MyFunction(char* outCharPtr, string& outStr, int& outInt, long& outLong) { outCharPtr = new char[2]; outCharPtr[0]...

Swig Python not wrapping methods

python,c,swig
I am attempting to wrap with SWIG a c file that has a long list of user defined include "*.h" files. Looking at the swig complied *.py file all methods contained in certain *.h files seemed to be included in wrapped code and none of the methods in different *.h...

SWIG wrap boost::none_t in Java

swig
I have following c++ functions for which i am making Java wrapper void label(const std::string &label) { // wrapper correctly built ... } void label(const boost::none_t t) { // generating SWIGTYPE_p_boost__none_t ... } How can i correctly wrap boost::none_t in Java. I m new to SWIG. Any help is appreciated...

SWIG parser error

swig
I have following header file. #include <string> namespace A { namespace B { struct Msg { std::string id; std::string msg; Msg(std::string new_id, std::string new_msg) : id(new_id), msg(new_msg) { } }; template<bool HAS_ID> class ID { public: template<typename TOBJ> auto get(TOBJ parent) -> decltype(parent.id()) { return parent.id(); } }; } //...

Segmentation fault when signing a message using OpenSSL, SWIG, and Perl

c,perl,openssl,swig,ecdsa
We were using SWIG to make a C cryptographic utility library available to Perl. We are able to generate keys, create digests, but the signing code causes a segmentation fault, which we believe may be in the OpenSSL code itself but it's difficult to be sure. This problem only comes...

How to prevent of Python 2.7 from including in a Python wrapper generated by SWIG?

python,c++,swig
I am developing a C++ library in which SWIG is used to generate its Python wrapper. Some of my C++ files use <inittypes.h> to call PRId64 and other macros in sprintf. I was able to compile my library with Python 2.6 and GCC 4.4.7 on Scientific Linux 6 (RHEL6 clone),...

Swig wrapper for variable argument lengths

python,c,swig,wrapping
I am trying to wrap the method below with swig and I seem to be having some trouble with the way argc and agrv values are being passed into the rtserver.c method below from server.py. int initialize(int run, int argc,char *argv[]) { This is the part of rtserver.i that should...

SWIG return PyObject as python object?

python,numpy,swig
Suppose I have a SWIG-wrapped class taking care of a pointer to some data, as shown in the following code. I would like to construct a numpy ndarray object from the data and return it to the user. I want it to use the data as it's buffer but not...

SWIG + Go: C source files not allowed when not using cgo

go,build,swig
I am trying to wrap this library (https://github.com/lemire/EWAHBoolArray) in Go using SWIG, but I'm having a lot of problems since I upgraded to 1.4 I had successfully gotten everything to work using Go 1.3.3 and following the instructions on the SWIG site for SWIG + Go. I had to compile...

Passing structure between Python and C using SWIG

python,c,binding,struct,swig
I’m trying to pass a structure between C and Python using SWIG. I am completely new to Python and C. I searched for passing structure using SWIG, without success. I based my code on examples from SWIG Python tutorial, page 55 and 56. It should fetch the input values from...

How to use swig with compiled dll and header file only

python,c++,dll,wrapper,swig
I have read some docs from SWIG documentation (related to c++ code), but can't figure out if it is possible to genereate Python extension module in case I have compiled dll (no source code provided) and header file with all functions declared in dll. If someone has the same problem...

How to manage the Ruby Garbage collector with swig

c++,ruby,swig
I have a C++ interface for which I create ruby bindings with swig. I am able to build those bindings but I have a problem with the Garbage Collector. My ruby code looks like this: parser = HeaderParser.new(source_file, ['/usr/lib']) parser.parse functions = parser.getFunctions //Array of Ruby wrapped class named Function...

Converting Strings in Linux using SWIG for Python

python,c++,linux,swig
I have a C++ class that is able to output strings in normal ASCII or wide format. I want to get the output in Python as a string. I am using SWIG (version 3.0.4) and have read the SWIG documentation. I'm using the following typemap to convert from a standard...

How do I change the constructor code in SWIG generated CSHARP file

c#,c++,constructor,swig
I have a C++ DLL for which I have generated C# code using SWIG tool. The intermediary class has the following method (assuming the module name is MyModule) in the PINVOKE.cs file: static MyModulePINVOKE() { ... } I want to perform a module initialization which can be done in SWIG...

Segmentation Fault (Core Dumped) when calling a python file from C++ .so

python,c++,opencv,ubuntu,swig
I am trying to generate C++ based .SO file along with wrapper by using swig. This .SO was generated to make a call from python(Ubuntu Environment). It works well if i tried with Simple C++ code, but when i try to build with OpenCV, facing some issues. opencvtest.cpp: #include <opencv2/core/core.hpp>...

How to compile PHP extension on OS X using SWIG

php,c,osx,shared-libraries,swig
I have a program written on C and need to use it in the PHP project. I succeed to use SWIG and compiled SO php extension on Ubuntu. Afterwards I've tried to use same SO file on OS X - but php throws following error: PHP Error[2]: dl(): Unable to...

How to set JSON object in variable using swig node js?

node.js,express,swig
I want to set a JSON object in client side javascript using swig. I tried with json filter of swig but it just print JSON object not assign. <script type="text/javascript"> var bootstrap = "{{locals.bootstrap | json}}"</script> as we know in Javascript this bootstrap variable is globally accessible in whole the...

Extracting SWIG wrapped C++ instance/pointer for use in Cython

python,c++,swig,cython,cpython
I have an instance of a class from SWIG-wrapped C++ library from which I would like to extract its reference, in order to be able to use it inside a Cython file, in which I am directly linking to the same C++ library by using a more lightweight self-made Cython...

Syntax error when include OpenCV core.hpp in SWIG

c++,opencv,go,swig
I'm trying to use SWIG to wrap OpenCV's C++ API. However, when I compile, I got this error: /usr/local/Cellar/opencv/2.4.10.1/include/opencv2/core/core.hpp:123: Error: Syntax error - possibly a missing semicolon. and here is my SWIG file %module example %{ #include "opencv2/core/core.hpp" %} %include "opencv2/core/core.hpp" I'm not sure if this is an error from...

SWIG immutable std::map reference

c++,swig
I have a typedef in C++ that looks like the following: typedef std::map<int, TestClass> TestClassMap; I have another class that returns a const TestClassMap&. Then in my interface (.i) file for SWIG, I have the following: namespace std { %template(TestClassMap) map<int, myNamespace::TestClass>; } This compiles fine and creates the C#...

swig.exe gives error illegal token É on creating C# wrapper

swig
i'm using swig tool to create c# wrapper for a dll.i used command swig.exe -csharp modbusm.dll but gives error illegal token i have also downloaded latest swig from github and compiled using minGW, but give same error. am i using Swig in right way ?...

How can I reuse code across swig typemaps?

python,c++,swig
I have two swig typemaps with a bunch of duplicate code in them. I'd like to consolidate the code as follows: %{ #include "structure_defs.h" %} %ignore Cartesian2PyList(const schrodinger::Cartesian&); PyObject* Cartesian2PyList(const schrodinger::Cartesian& cartesian) { PyObject *o; o = PyList_New(3); PyObject* item = PyFloat_FromDouble(cartesian.x); PyList_SetItem(o, 0, item); item = PyFloat_FromDouble(cartesian.y); PyList_SetItem(o, 1,...

SWIG: How to change the autogenerated “delete_xxx” code

c++,swig,auto-generate
I have the following declarations in SWIG interface file and a class named Test : %extend qual_name { public: ~short_name() { //Do something here }; } The above declarations generate a SWIGINTERN void delete_Test(Test* self) method in the swig generated CPP file. The problem is that I have a lot...

pip can't install package because it can't find swig2.0 binary

python-2.7,pip,swig
I'm using python 2.7.9 (64 bit) with pip 1.5.6 and virtualenv 12.1.1 on Windows 7 powershell. I created a virtual environment named NeuralNetwork and I'm trying to install the package fann2 1.0.7: PS C:\Python27\envs\NeuralNetwork\Scripts> pip.exe install fann2 Collecting fann2 (...) Exception: Couldn't find swig2.0 binary! I guess I have to...

Python: AttributeError: 'module' object has no attribute

python,swig
I used swig to create a python file from c. I have converted the c file into .py file and when I try to invoke a function of the c program, I am getting an error AttributeError: 'module' object has no attribute 'fact' My C file is /* File :...

How to access Rust from other languages

rust,swig
Previously when the code-base was in C++, I had C++ wrapper files which would link to the code base and I would run swig (version 3 for C++11 support) to generate the interface files for the target language (Python, JavaScript, C#, etc.). Then of course get all these files and...

Dereferencing pointer to incomplete type error for struct member access in Python swig C wrapper

python,c,gcc,compiler-errors,swig
What is the error while compiling swig Python wrapper under GCC 4.8.2? wfdb_python_wrap.c:3967:11: error: dereferencing pointer to incomplete type if (arg1->fname) free((char*)arg1->fname); ^ wfdb_python_wrap.c:3967:36: error: dereferencing pointer to incomplete type if (arg1->fname) free((char*)arg1->fname); source code from wfdb_python_wrap.c: ... #include <wfdb/wfdb.h> ... #ifdef __cplusplus extern "C" { #endif SWIGINTERN PyObject *_wrap_WFDB_Siginfo_fname_set(PyObject...

Include an enum from within a class, without including the in SWIG

c++,enums,swig
Some of the interfaces i have to map with SWIG are using interfaces from classes i other libraries. For example i have a parameter of type const boost::asio::ssl::context::file_format which is refering to an enum defined as: // ssl/context_base.hpp // ~~~~~~~~~~~~~~~~~~~~ // [...] namespace boost { namespace asio { namespace ssl...

Why SWIG C# overloads fail?

c#,c++,.net,inheritance,swig
So having a simple code in C++. Having a C++ library with: class A{ public: virtual void Call(); virtual void CallCall(); virtual ~A(); }; And a swig file: %{ #include "A.h" %} %include "A.h" %module(directors="1") TestSWIG; %feature("director") A; After calling SWIG generator, including generated C++ and C# files into related...

How to create an extension to already wrapped library via SWIG?

c++,c,plugins,shared-libraries,swig
I have a library. It is wraped via SWIG. I want to create a plugin to extend it. Plugin requires a class from already wrapped library to run having something like void init( oldT old);. Library is used from Java and c#. Now this plugin also will be used from...

can eclipse CDT be used in place of vc++ inorder to call C++ library in node.js by using SWIG?

javascript,c++,node.js,eclipse-cdt,swig
I have a C++ library which I want to call in node.js. For that I opted for SWIG. But it requires to use visual studio c++. My preference is eclipse CDT. Is there any way SWIG be used with eclipse? Also is there any other tool or Addon that could...

Make SWIG wrapped builtin class “hashable” in Python

python,python-2.7,hashmap,swig
I use SWIG to expose our C++ libraries to Python. For performance reasons, I'm interested in switching some of the wrapping to use SWIG's -builtin option, which removes the layers of Python proxy objects. However, the wrapped class can no longer be used in Python sets or as a key...