swig

SWIG ImportError: undefined symbol: _Py_RefTotal

丶灬走出姿态 提交于 2019-12-11 03:49:55
问题 I am really new to SWIG. I tried to compile the example given in SWIG but I get the following error: $ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import example Traceback (most recent call last): File "<stdin>", line 1, in <module> File "example.py", line 25, in <module> _example = swig_import_helper() File "example.py", line 21, in swig_import_helper _mod = imp.load_module('_example'

Compiling SWIG wrapper for python in Windows

点点圈 提交于 2019-12-11 03:34:48
问题 First, thank all of you for all the answer you gave me on this forum the last years, but today I couldn't find a clear answer and so I though It was time to post. I manage to compile and run a C++ code test5.cpp on my Debian distrib, wrapping it ( maybe it's not the right word) into a python module Amod.py with SWIG ( which necessitate a "translation" file test5.i .I used and import successfully the module for data analysis into other more complex python code ( basically manipulation of numpy

Basic assignment of swig wrapped variables fails

一个人想着一个人 提交于 2019-12-11 03:24:13
问题 I created a lua module with a very large number of wrapped C++ classes using swig. The wrappers are generated and compiled (with -Wall) without any issues. However, in a couple of places that I've found, I run into the following issue: basic assignment of member data fails. If I run: Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio > require('myModule') > a = myModule.ClassA() I can then verify that the metatable attached to "a" contains all of its member data (in this case fields "b" and

Create SWIG C# wrapper for function that contains void* parameter

情到浓时终转凉″ 提交于 2019-12-11 03:20:29
问题 I'm trying to create a C# wrapper for a C .lib that contains functions take take a void pointer using SWIG. int inputPointExample(void* input); int outputPointerExample(void* output); By default SWIG doesn't handle void pointer conversions, you have to use typemaps somehow. I found this page -> http://www.nickdarnell.com/2011/05/swig-and-a-miss/ Number 9 says to use the following typemaps to handle void pointers... %typemap(ctype) void * "void *" %typemap(imtype) void * "IntPtr" %typemap

How to use a JNI native library from Grails application

混江龙づ霸主 提交于 2019-12-11 03:09:01
问题 I'm developing a Grails web application and I need to use a JNI native library to access some specific hardware. For a simple Java application (see below) it works fine. To do this I just have to add the JAR to the Java build path and specify the "Native library location" (I use SpringSource Tool Suite on Windows7). Working example: import conceptacid.nativedriver.Driver; public class Main { public static void main(String[] args) { System.out.println("starting..."); System.loadLibrary(

SWIG and polymorphic C# using %typemap

寵の児 提交于 2019-12-11 02:51:57
问题 I would like to support downcasting in a SWIG-generated C# project. I have a series of C++ std::shared_ptr -wrapped class templates that inherit from a common base. Any C++ method that returns a base class ( IBasePtr ) in C++ code results in a generated method that returns a concrete IBase object, which has no relation to the object I am actually trying to get. The blog post here deals with this exact problem by inserting custom code to perform a downcast based on object type metadata. C++

How to use float ** in Python with Swig?

拟墨画扇 提交于 2019-12-11 02:10:42
问题 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_,int **classes_); 回答1: This answer is a repost of one to a related question Framester posted about using ctypes instead of swig. I've included it here in case any web

Return list of new custom-class objects in python C API

允我心安 提交于 2019-12-11 01:53:16
问题 I need to create a new list via the python C API containing new copies of objects of a Quaternion class I've written (in C++). [Actually, I'd really like a numpy array, but any sort of sequence would do.] But I'm getting seg faults with everything I've tried. I'm terrible with pointers, so that's not a big surprise. I'm thinking maybe I need to give python ownership of the objects I create with new . The best I've gotten so far appears below. Am I not supposed to copy-construct the Quaternion

Is it possible to add “text” to an existing typemap in swig?

走远了吗. 提交于 2019-12-11 01:47:11
问题 I found this question, but the one answer was basically, you wouldn't want to do that: Is it possible to add code to an existing method when using Swig to build a C# wrapper for C++ code? I actually agree with it in the case as described, where the OP was trying to insert code in a way that could be fragile. In my case I am doing exactly what the answer suggested: renaming the method and using %typemap(javacode) to implement the wrapping method. But I've written this as a macro, and I want to

SWIG:Lua - Passing a c++ instance as a lua function parameter

≯℡__Kan透↙ 提交于 2019-12-11 00:49:20
问题 I'm exporting some c++ classes to Lua with SWIG. I have declared boost::filesystem::path in the SWIG interface file like this: namespace boost { namespace filesystem { class path {}; } } Now I want to call a function declared in a lua script which should take a boost::filesystem::path& as parameter to pass it to another object. I only need to be able to pass the path to the object. I don't need to use any functionality from the path object. function on_path_selected(the_path) another_object