swig

SWIG and Python3 Import Error

泄露秘密 提交于 2019-12-07 05:26:50
问题 I have written a library in C. I use SWIG to generate bindings for Java, Python, etc. I managed to write custom type maps for both languages and so on. I also managed to use my library (a custom protocol) and communicate with a server that I wrote in C, with a client that I wrote in Java and, with a client that I'm writing in Python. Recently, I came across a multiple inheritance problem with a solution I found smart. But, when trying to replicate the error using Python 3, the error was gone

SWIG: No typemaps are defined

半世苍凉 提交于 2019-12-07 05:02:37
问题 I have a c++ class that I am trying to wrap for Python using SWIG. I am having trouble trying to wrap one of the functions which takes an array as input. Here's the header file, class dyndiff_data_t { private: double H[3]; double GAMMA; double k; double P; public: dyndiff_data_t(double H_[3], const double GAMMA_, const double k_, const double P_); void test(); }; and here's the swig interface file, %module twowave %{ #define SWIG_FILE_WITH_INIT #include <twowave.h> %} %include "numpy.i" %init

Creating new classes/members at run-time in scripting languages used in C++ [closed]

非 Y 不嫁゛ 提交于 2019-12-07 04:08:17
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I've been working on this problem off and on for a few months, and now wanted to really come up with a proper solution that will handle the case of creating new user-defined classes (and instances of those classes) with member functions/properties at run-time in a C++11 project. So far, I've been using SWIG

SWIG python initialise a pointer to NULL

牧云@^-^@ 提交于 2019-12-07 03:43:34
问题 Is it possible to initialise a ptr to NULL from the python side when dealing with SWIG module? For example, say I have wrapped a struct track_t in a swig module m (_m.so), I can create a pointer to the struct from python as follows: import m track = m.track_t() this will just malloc a track_t for me in the appropriate wrapper function. I would however like to be able to achieve the following: track_t *track = NULL; But in python rather than C, e.g. initialise a pointer to NULL from the python

Convert std::set to ruby with Swig

假装没事ソ 提交于 2019-12-07 02:13:19
问题 I am using Swig to use C++ in ruby and Currently I have done a simple example of file david.h #include <stdio.h> class David { public: David(int x) { this->x = x; } void announce() { printf("David %d\n", x); } int x; }; And another file for swig like this %module "david" %{ #include <libdavid.h> %} class David { public: David(int x); void announce(); int x; }; My extconf.rb looks like this require 'mkmf' system('swig -c++ -ruby libdavid.i') or abort create_makefile('david') This helps me

SWIG generated code fails to run on PHP 5.3.2 undefined symbol: zend_error_noreturn

旧城冷巷雨未停 提交于 2019-12-07 02:10:18
问题 I have a library that I have been using successfully with PHP 5.1.6 with the help of some wrapper code generated by SWIG (v1.3.40). I have just upgraded to PHP 5.3.2 and I am seeing the following error: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/myLib_php.so' - /usr/lib/php/modules/myLib_php.so: undefined symbol: zend_error_noreturn in Unknown on line 0 On investigation it appears that the wrapper code produced by SWIG (myLib_wrap.c) includes calls to the

Swig error with Nested enums in C++

[亡魂溺海] 提交于 2019-12-07 02:02:46
I have a class similar to the following. It has a nested enum OptionTag. class MediaPacket { public: struct RtcpAppName { char mName[RTCP_APPNAME_LENGTH]; }; enum OptionTag { RESERVED = 0, PROFILE = 1, LATENCY = 2, PKTLOSS = 3, JITTER = 4, LEGACYMIX = 5, LASTTAG = 255 }; .... .... list<OptionTag> GetOptions(unsigned int ssrc) const; }; For this I created a swig interface as follows %module mediaopts_packet %include "stdint.i" //Redefining nested structure in swig struct RtcpAppName { char mName[RTCP_APPNAME_LENGTH]; }; %{ #define SWIG_FILE_WITH_INIT #include "../include/mediaopts_packet.h" %}

Heroku buildpacks - installing executables that are used by Python packages

岁酱吖の 提交于 2019-12-07 00:15:14
问题 I am trying to install M2Crypto on Heroku. This relies on SWIG being installed. I've created a custom compiled swig executable and a custom buildpack. I then git push my code up to Heroku, the custom buildpack installs SWIG then tries to install M2Crypto but fails because it can't find swig . This is the buildpack customisation: # Install SWIG if [ ! -d $CACHE_DIR/swig ]; then cd $BUILD_DIR echo "-----> Fetching and installing SWIG 2" curl -O https://s3.amazonaws.com/guybowden/swig.tar.gz >

Sphinx and documenting python from a swigged C++ api [duplicate]

倖福魔咒の 提交于 2019-12-06 20:55:28
This question already has answers here : Is there a good way to produce documentation for swig interfaces? (2 answers) Closed last year . I'm basically asking the same question as this: Is there a good way to produce documentation for swig interfaces? However, that one was like two years old and now there is sphinx. Question is, can sphinx automatically get something out from the python code that swig produces, or does one need to manually 're-enter' the documentation that is in the C++ code? SWIG does not yet support extracting class/method/function documentation from comments in C++ header

segfault using SWIG converted code for tcl

旧城冷巷雨未停 提交于 2019-12-06 17:01:30
I'm having a segmentation fault with my program. In fact I write a library in C++ and convert it for tcl using SWIG. The segfault occurs here: return Tcl_NewIntObj(static_cast< int >(value)); where value=0 the gdb back trace shows: (gdb) bt #0 0x000054b6 in ?? () #1 0xb6650d5d in SWIG_From_long (value=0) at mntdisplay_wrap.cc:1712 #2 SWIG_From_int (value=0) at mntdisplay_wrap.cc:1722 #3 Testguimnt_Init (interp=0x9714e28) at mntdisplay_wrap.cc:3774 #4 0xb76748fe in Tcl_LoadObjCmd () from /opt/ActiveTcl-8.6/lib/libtcl8.6.so #5 0xb75d02af in TclNREvalObjv () from /opt/ActiveTcl-8.6/lib/libtcl8.6