Search Results

Search found 107 results on 5 pages for 'swig'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • M2Crypto doesn't install in venv, or swig doesn't define __x86_64__ which breaks compiling against OpenSSL

    - by Lorin Hochstein
    I'm trying to install the Python M2Crypto package into a virtualenv on an x86_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.tar.gz (412Kb): 412Kb downloaded Running setup.py egg_info for package M2Crypto Installing collected packages: M2Crypto Running setup.py install for M2Crypto building 'M2Crypto.__m2crypto' extension swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c swig -python -I/usr/include/python2.6 -I/usr/include -includeall -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i /usr/include/openssl/opensslconf.h:31: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing. error: command 'swig' failed with exit status 1 Complete output from command /home/lorin/venv/bin/python -c "import setuptools;__file__='/home/lorin/venv/build/M2Crypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-BFiNtU-record/install-record.txt --install-headers /home/lorin/venv/include/site/python2.6: I've got OpenSSL 1.0.0 installed via RPM packages from RedHat. The part of /usr/include/openssl/opensslconf.h that causes the error looks like this: #if defined(__i386__) #include "opensslconf-i386.h" #elif defined(__ia64__) #include "opensslconf-ia64.h" #elif defined(__powerpc64__) #include "opensslconf-ppc64.h" #elif defined(__powerpc__) #include "opensslconf-ppc.h" #elif defined(__s390x__) #include "opensslconf-s390x.h" #elif defined(__s390__) #include "opensslconf-s390.h" #elif defined(__sparc__) && defined(__arch64__) #include "opensslconf-sparc64.h" #elif defined(__sparc__) #include "opensslconf-sparc.h" #elif defined(__x86_64__) #include "opensslconf-x86_64.h" #else #error "This openssl-devel package does not work your architecture?" #endif gcc has the right variable defined: $ echo | gcc -E -dM - | grep x86_64 #define __x86_64 1 #define __x86_64__ 1 But apparenty swig doesn't, since this is the line that's failing: swig -python -I/usr/include/python2.6 -I/usr/include -includeall -o \ SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i Is there a way to fix this by changing something in my system configuration? M2Crypto gets installed in a virtualenv as part of a larger script I don't control, so avoiding mucking around with the M2Crypto files would be a good thing.

    Read the article

  • Compiling SWIG library for Ruby on Mac OS X fails

    - by Stefan Schmidt
    I tried to compile the following SWIG library for Ruby 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.8/i686-darwin10 $ gcc -shared computation.o computation_wrap.o -o computation.so Undefined symbols: "_rb_str_cat", referenced from: _Ruby_Format_TypeError in computation_wrap.o "_rb_exc_new3", referenced from: _SWIG_Ruby_ExceptionType in computation_wrap.o "_rb_define_class_under", referenced from: _SWIG_Ruby_define_class in computation_wrap.o _SWIG_Ruby_define_class in computation_wrap.o [...] ld: symbol(s) not found collect2: ld returned 1 exit status My configuration: $ sw_vers ProductName: Mac OS X ProductVersion: 10.6.3 BuildVersion: 10D575 $ ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10] $ swig -version SWIG Version 1.3.40 Compiled with /usr/bin/g++-4.2 [i386-apple-darwin10.3.0] $ gcc --version i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646)

    Read the article

  • creating PHP C/C++ extension modules using SWIG

    - by morpheous
    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 like using it quite a lot. I am thinking of using SWIG to generate my future PHP extensions. I am using PHP v5.2 (and above) on my production servers. My questions are: Is SWIG PHP interface stable yet (i.e. ready for production)? If you answered yes to question 1 -are YOU using it in YOUR production site? Are there any 'gotchas' I need to be aware of when creating PHP extension ,modules using SWIG?

    Read the article

  • SWIG interface to receive an opaque struct reference in Java through function argument

    - by Beeo
    I am trying to use SWIG in order to use the Spotify API (libspotify) for Android: https://developer.spotify.com/technologies/libspotify/ I am having trouble defining the SWIG interface file to be able to successfully call the following native C function: sp_error sp_session_create(const sp_session_config * config, sp_session ** sess); Which in C would be called like this: //config struct defined previously sp_session *sess; sp_session_create(&config, &sess); But in Java I would need to call it like this: //config object defined previously sp_session javaSess = new sp_session(); sp_session_create(config, javaSess); sp_session is an opaque struct and is only defined in libspotify's API.h file as: typedef struct sp_session sp_session; I'm expecting the libspotify library to create it and give me a reference to it. The only thing I need that reference for then is to pass to other functions in the API. I believe the answer lies within the SWIG interface and typemaps, but I have been unsuccessful in trying to apply the examples I found in the documentation: http://www.swig.org/Doc2.0/SWIGDocumentation.html#Java_struct_pointer_pointer `http://www.swig.org/Doc2.0/SWIGDocumentation.html#Java_using_typemaps_return_arguments Help!

    Read the article

  • Basic SWIG C++ use for Java

    - by duckworthd
    I've programmed a couple years in both C++ and Java, but I've finally come to a point where I need to bring a little unification between the two -- ideally, using SWIG. I've written a tiny and fairly pointless little class called Example: #include <stdio.h> class Example { public: Example(); ~Example(); int test(); }; #include "example.h" Example::Example() { printf("Example constructor called\n"); } Example::~Example() { printf("Example destructor called\n"); } int Example::test() { printf("Holy sh*t, I work!\n"); return 42; } And a corresponding interface file: /* File: example.i */ %module test %{ #include "example.h" %} %include "example.h" Now I have questions. Firstly, when I want to actually run SWIG initially, am I supposed to use the example_wrap.c (from swig -java example.i) or example_wrap.cxx (from swig -c++ example.i) file when recompiling with my original example.cpp? Or perhaps both? I tried both and the latter seemed most likely, but when I recompile as so: g++ example.cpp example_wrap.cxx -I/usr/lib/jvm/java-6-sun-.../include/ I get a host of errors regarding TcL of all things, asking me for the tcl.h header. I can't even wrap my mind around why it wants that much less needs it, and as such have found myself where I don't even know how to begin using SWIG.

    Read the article

  • module compiled with swig not found by python

    - by openbas
    Hello, I've a problem with SWIG and python. I've a c-class that compiles correctly, but the python script says it can't find the module. I compile with: swig -c++ -python codes/codes.i g++ -c -Wall -O4 -fPIC -pedantic codes/*.cc g++ -I/usr/include/python2.6 -shared codes/codes_wrap.cxx *.o -o _codes.so This gives me a _codes.so file, as I would expect, but then I have this python file: import sys import codes (rest of the code omitted) It gives me: Traceback (most recent call last): File "script.py", line 3, in <module> import codes ImportError: No module named codes According to http://www.swig.org/Doc1.3/Introduction.html#Introduction_nn8 this is all I should have to do... The files are in the same directory, so the path should not be a problem ?

    Read the article

  • SWIG & Java Use of carrays.i and array_functions for C Array of Strings

    - by c12
    I have the below configuration where I'm trying to create a test C function that returns a pointer to an Array of Strings and then wrap that using SWIG's carrays.i and array_functions so that I can access the Array elements in Java. Uncertainties: %array_functions(char, SWIGArrayUtility); - not sure if char is correct inline char *getCharArray() - not sure if C function signature is correct String result = getCharArray(); - String return seems odd, but that's what is generated by SWIG SWIG.i: %module Test %{ #include "test.h" %} %include <carrays.i> %array_functions(char, SWIGArrayUtility); %include "test.h" %pragma(java) modulecode=%{ public static char[] getCharArrayImpl() { final int num = numFoo(); char ret[] = new char[num]; String result = getCharArray(); for (int i = 0; i < num; ++i) { ret[i] = SWIGArrayUtility_getitem(result, i); } return ret; } %} Inline Header C Function: #ifndef TEST_H #define TEST_H inline static unsigned short numFoo() { return 3; } inline char *getCharArray(){ static char* foo[3]; foo[0]="ABC"; foo[1]="5CDE"; foo[2]="EEE6"; return foo; } #endif Java Main Tester: public class TestMain { public static void main(String[] args) { System.loadLibrary("TestJni"); char[] test = Test.getCharArrayImpl(); System.out.println("length=" + test.length); for(int i=0; i < test.length; i++){ System.out.println(test[i]); } } } Java Main Tester Output: length=3 ? ? , SWIG Generated Java APIs: public class Test { public static String new_SWIGArrayUtility(int nelements) { return TestJNI.new_SWIGArrayUtility(nelements); } public static void delete_SWIGArrayUtility(String ary) { TestJNI.delete_SWIGArrayUtility(ary); } public static char SWIGArrayUtility_getitem(String ary, int index) { return TestJNI.SWIGArrayUtility_getitem(ary, index); } public static void SWIGArrayUtility_setitem(String ary, int index, char value) { TestJNI.SWIGArrayUtility_setitem(ary, index, value); } public static int numFoo() { return TestJNI.numFoo(); } public static String getCharArray() { return TestJNI.getCharArray(); } public static char[] getCharArrayImpl() { final int num = numFoo(); char ret[] = new char[num]; String result = getCharArray(); System.out.println("result=" + result); for (int i = 0; i < num; ++i) { ret[i] = SWIGArrayUtility_getitem(result, i); System.out.println("ret[" + i + "]=" + ret[i]); } return ret; } }

    Read the article

  • Swig typecast to derived class?

    - by Zack
    I notice that Swig provides a whole host of functions to allow for typecasting objects to their parent classes. However, in C++ one can produce a function like the following: A * getAnObject() { if(someBoolean) return (A *) new B; else return (A *) new C; } Where "A" is the parent of classes "B" and "C". One can then typecast the pointer returned into being a "B" type or "C" type at one's convenience like: B * some_var = (B *) getAnObject(); Is there some way I can typecast an object I've received from a generic-pointer-producing function at run-time in the scripting language using the wrappers? (In my case, Lua?) I have a function that could produce one of about a hundred possible classes, and I'd like to avoid writing an enormous switch structure that I'd have to maintain in C++. At the point where I receive the generic pointer, I also have a string representation of the data type I'd like to cast it to. Any thoughts? Thanks! -- EDIT -- I notice that SWIG offers to generate copy constructors for all of my classes. If I had it generate those, could I do something like the following?: var = myModule.getAnObject(); -- Function that returns an object type-cast down to a pointer of the parent class, as in the function getAnObject() above. var = myModule.ClassThatExtendsBaseClass(var); -- A copy constructor that SWIG theoretically creates for me and have var then be an instance of the inheriting class that knows it's an instance of the inheriting class?

    Read the article

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

    - by sambha
    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 simple class. Used SWIG to wrap this class. This DLL is the _MyClasses.pyd. test.py creates the objects of my class & calls its member functions. All this works like a charm in the Release mode. But does not work in Debug mode (even tried banging my head on the laptop ;-) ). Output of my work looks like this (in both release & debug): x64 -debug - _MyClasses.pyd - MyClasses.py - test.exe - test.py - python26.dll - python26_d.dll Note that the debug version is linked against python26_d.lib. Had to build python myself for this! test.py import MyClasses print "ello" m = MyClasses.Male("John Doe", 25) print m.getType() Male is the C++ class. The problem: Traceback (most recent call last): File "test.py", line 6, in <module> import MyClasses File "...\x64\Debug\MyClasses.py", line 25, in <module> _MyClasses = swig_import_helper() File "...\x64\Debug\MyClasses.py", line 17, in swig_imp ort_helper import _MyClasses ImportError: No module named _MyClasses [15454 refs] I am used to Makefiles & am new to Visual Studio. I dont know who the culprit is here: Swig, The debug build of Python, Visual Studio, my stupidity. Thank you in advance. It will be a great help.

    Read the article

  • Generating python wrapper for 3ed party c++ dll using swig with

    - by MuraliK
    I am new bee to swig. I have a third party c++ dll with the following functions export. I want to call these dll functions in python. So thought of using swig to generate the wrapper using swig. I am not sure what sort of wrapper i need to generate (do i need to generate .lib or .dll to use it in python?). In case i need to generate .dll how do i do that using visual studio 2010. There are some call back function like SetNotifyHandler(void (__stdcall * nf)(int wp, void *lp)) in the bellow list. How do define such function in interface file. can someone help me plese? enter code here #ifndef DLL_H #define DLL_H #ifdef DLL_BUILD #define DLLFUNC __declspec(dllexport) #else #define DLLFUNC __declspec(dllimport) #endif #pragma pack(push) #pragma pack(1) #pragma pack(pop) extern "C" { DLLFUNC int __stdcall StartServer(void); DLLFUNC int __stdcall GetConnectionInfo(int connIndex, Info *buf); DLLFUNC void __stdcall SetNotifyWindow(HWND nw); DLLFUNC void __stdcall SetNotifyHandler(void (__stdcall * nf)(int wp, void *lp)); DLLFUNC int __stdcall SendCommand(int connIndex, Command *cmd); };

    Read the article

  • Eclipse Pydev: Supress no-self errors in python wrappers generated with swig

    - by Christian
    Hi, when generating python wrappers with swig the python wrapper classes in the generated python file do not have an explicit self parameter, for example see below: class PySwigIterator(_object): def value(*args): return _spatiotemporalnmf.PySwigIterator_value(*args) def incr(*args): return _spatiotemporalnmf.PySwigIterator_incr(*args) def decr(*args): return _spatiotemporalnmf.PySwigIterator_decr(*args) def distance(*args): return _spatiotemporalnmf.PySwigIterator_distance(*args) I am developing with the eclipse pluging Pydev. Pydev always shows an error when it detects a method without explicit self parameter. I am aware of two methods to get rid of the errors: First, disable error checking for the whole project in the Pydev preferences. Second, add a #@NoSelf to every line with an error. I don't want to use the first one, because I still want to get error warnings for my non-swig-generated files. Obviously the second one is also not very good, because I would have to do it by hand and every time I generate the file again, all #@NoSelfs will be gone. My Question now is, is there a better way to achieve this? Thanks

    Read the article

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

    - by wookiebreath
    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 PHP function: zend_error_noreturn and that this function isn't available in PHP 5.3.2? Has anyone seen this issue before? Things seem to work if I manually update the generated code so that instead of calling zend_error_noreturn it just calls zend_error. Is this approach safe?

    Read the article

  • Python, SWIG and other strange things

    - by wanderameise
    hey, I have a firmware for an USB module I can already control by visual C. Now I want to port this to python. for this I need the octopus library which is written in c. I found a file called octopus_wrap which was created by SWIG! then I found a makefile which says: python2.5: swig -python -outdir ./ ../octopus.i gcc -fPIC -c ../../liboctopus/src/octopus.c gcc -fPIC -c ../octopus_wrap.c -I /usr/include/python2.5 gcc -fPIC -shared octopus_wrap.o octopus.o /usr/lib/libusb.so -o _octopus.so python2.4: swig -python -outdir ./ ../octopus.i gcc -fPIC -c ../../liboctopus/src/octopus.c gcc -fPIC -c ../octopus_wrap.c -I /usr/include/python2.4 gcc -fPIC -shared octopus_wrap.o octopus.o /usr/lib/libusb.so -o _octopus.so win: gcc -fPIC -c ../../liboctopus/src/octopus.c -I /c/Programme/libusb-win32-device-bin-0.1.10.1/include gcc -fPIC -c octopus_wrap.c -I /c/Python25/libs -lpython25 -I/c/Python25/include -I /c/Programme/libusb-win32-device-bin-0.1.10.1/include gcc -fPIC -shared *.o -o _octopus.pyd -L/c/Python25/libs -lpython25 -lusb -L/c/Programme/libusb-win32-device-bin-0.1.10.1/lib/gcc clean: rm -f octopus* _octopus* install_python2.4: cp _octopus.so /usr/local/lib/python2.4/site-packages/ cp octopus.py /usr/local/lib/python2.4/site-packages/ install_python2.5: cp _octopus.so /usr/local/lib/python2.5/site-packages/ cp octopus.py /usr/local/lib/python2.5/site-packages/ I dont know how to handle this but as far as I can see octopus.py and _octopus.so are the resulting output files which are relevant to python right? luckily someone already did that and so I put those 2 files to my "python26/lib" folder (hope it doesnt matter if it´s python 2.5 or 2.6?!) So when working with the USB device the octopus.py is the library to work with! Importing this file makes several problems: >>> Traceback (most recent call last): File "C:\Users\ameise\My Dropbox\µC\AVR\OCTOPUS\octopususb-0.5\demos\python \blink_status.py", line 8, in <module> from octopus import * File "C:\Python26\lib\octopus.py", line 7, in <module> import _octopus ImportError: DLL load failed: module not found. and here´s the related line 7 : import _octopus So there´s a problem considering the .so file! What could be my next step? I know that´s a lot of confusing stuff but I hope anyone of you could bring some light in my mind! thy in advance

    Read the article

  • How to stringfy a swig matrix object in python

    - by leo
    Hi, I am using swig wrapper of openbabel(written in C++, and supply a python wrapper through swig) Below i just use it to read a molecule structure file and get the unitcell property of it. import pybel for molecule in pybel.readfile('pdb','./test.pdb'): unitcell = molecule.unitcell print unitcell |.. |.. The unitcell has function CellMatrix(), unitcell.GetCellMatrix() <22 the OpenBabel::matrix3x3 is something like : 1 2 3 4 5 6 7 8 9 i am wondering how to print out the contents of the matrix3*3 . I have tried str and repr with it. Any general way to stringfy the contents of a matrix wrapped by swing in python ? thanks

    Read the article

  • wrapping boost::ublas with swig

    - by leon
    I am trying to pass data around the numpy and boost::ublas layers. I have written an ultra thin wrapper because swig cannot parse ublas' header correctly. The code is shown below #include <boost/numeric/ublas/vector.hpp> #include <boost/numeric/ublas/matrix.hpp> #include <boost/lexical_cast.hpp> #include <algorithm> #include <sstream> #include <string> using std::copy; using namespace boost; typedef boost::numeric::ublas::matrix<double> dm; typedef boost::numeric::ublas::vector<double> dv; class dvector : public dv{ public: dvector(const int rhs):dv(rhs){;}; dvector(); dvector(const int size, double* ptr):dv(size){ copy(ptr, ptr+sizeof(double)*size, &(dv::data()[0])); } ~dvector(){} }; with the SWIG interface that looks something like %apply(int DIM1, double* INPLACE_ARRAY1) {(const int size, double* ptr)} class dvector{ public: dvector(const int rhs); dvector(); dvector(const int size, double* ptr); %newobject toString; char* toString(); ~dvector(); }; I have compiled them successfully via gcc 4.3 and vc++9.0. However when I simply run a = dvector(array([1.,2.,3.])) it gives me a segfault. This is the first time I use swigh with numpy and not have fully understanding between the data conversion and memory buffer passing. Does anyone see something obvious I have missed? I have tried to trace through with a debugger but it crashed within the assmeblys of python.exe. I have no clue if this is a swig problem or of my simple wrapper. Anything is appreciated.

    Read the article

  • Debugging segfault on swig/python/c++

    - by Pradyot
    I am trying to figure out what the best way to debug a segault with swig/python/c++. A core file is being generated. I have a basic MessageFactory(defined in c++ that provides a simple interface to accept a few strings as input and return a string as output). This interface is then specified in a .i file. swig is used to generate Wrapper.cpp as well as a MessageFactory.py from the .i file. This along with supporting files is compiled into a dynamic lib. The point of failure , is when the MessageFactory is instantiated within python code. Any suggestions on how I can go about debugging this? I've tried running the script within pdb, what I know from that is import on the generated MessageFactory.py is whats causing the seg-fault.

    Read the article

  • Syntax error in SWIG using __thread keyword

    - by user366838
    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[Num_Buckets]; and the error occurs when I change it to: static __thread void *freeLists[Num_Buckets]; I have made other parts thread safe adding "__thread", for example, this works: static __thread unsigned newCount[Num_Buckets];

    Read the article

  • C++'s char * by swig got problem in Python 3.0

    - by gpliu3
    Our C++ lib works fine with Python2.4 using Swig, returning a C++ char* back to a python str. But this solution hit problem in Python3.0, error is: Exception=(, UnicodeDecodeError('utf8', b"\xb6\x9d\xa.....",0, 1, 'unexpected code byte') Our definition is like(working fine in Python 2.4): void cGetPubModulus( void* pSslRsa, char* cMod, int* nLen ); %include "cstring.i" %cstring_output_withsize( char* cMod, int* nLen ); Suspect swig is doing a Bytes-Str conversion automatically. In python2.4 it can be implicit but in Python3.0 it's no long allowed.. Anyone got a good idea? thanks

    Read the article

  • SWIG-Lua question on class returning another class

    - by John Smith
    I am concreting a question I had earlier. I have two classes in C++ and I use SWIG to wrap them. A method in one class can return a pointer to the other class. How can I get Lua to see it as more than just a userdata? More concretely: I have class fruit { int numberofseeds; //some other stuff about fruit constructors etc... public: getseedcount() { return numberofseeds; } } class tree { fruit * apple; public: //constructors and whatnot fruit * getfruit() { return apple; } } I wrap these two class with SWIG so I can access them in Lua So I can get in Lua the object x=pomona.tree(grannysmith). My question now is: How can I arrange for things so that when I type y=x:getfruit() I will get a pomona:fruit type object? Where I can write something line y:getseedcount()? At the moment all I get is userdata which not edible.

    Read the article

  • SWIG: C++ to C#, pointer to pointer marshalling.

    - by CaRT
    I have some legacy code I want to port to C#. I cannot modify the C++ code, I just have to make do with what I'm given. So, the situation. I'm using SwIG, and I came across this function: void MarshalMe(int iNum, FooClass** ioFooClassArray); If I ran SWIG over this, it wouldn't know what to do with the array, so it will create a SWIGTYPE_p_pFooClass. Fair enough! C# code for this would look like void MarshalMe(int iNum, SWIGTYPE_p_p_FooClass ioFooClassArray); // Not ideal! There are some techniques for marshalling this kind of code correctly, so I tried a few of them: %typemap(ctype) FooClass** "FooClass**" %typemap(cstype) FooClass** "FooClass[]" %typemap(imtype, inattributes="[In, Out, MarshalAs(UnmanagedType.LPArray)]") FooClass** "FooClass[]" %typemap(csin) FooClass** "$csinput" %typemap(in) FooClass** "$1 = $input;" %typemap(freearg) FooClass** "" %typemap(argout) FooClass** "" This effectively creates a nicer signature: void MarshalMe(int iNum, FooClass[] ioFooClassArray); // Looks good! Would it work? However, when I try to run it, I get the following error: {"Exception of type 'System.ExecutionEngineException' was thrown."} Any ideas about the actual typemap?

    Read the article

  • handling refrence to pointers/double pointers using SWIG [C++ to Java]

    - by Siddu
    My code has an interface like class IExample { ~IExample(); //pure virtual methods ...}; a class inheriting the interface like class CExample : public IExample { protected: CExample(); //implementation of pure virtual methods ... }; and a global function to create object of this class - createExample( IExample *& obj ) { obj = new CExample(); } ; Now, I am trying to get Java API wrapper using SWIG, the SWIG generated interface has a construcotr like - IExample(long cPtr, boolean cMemoryOwn) and global function becomes createExample(IExample obj ) The problem is when i do, IExample exObject = new IExample(LogFileLibraryJNI.new_plong(), true /*or false*/ ); createExample( exObject ); The createExample(...) API at C++ layer succesfully gets called, however, when call returns to Java layer, the cPtr (long) variable does not get updated. Ideally, this variable should contain address of CExample object. I read in documentation that typemaps can be used to handle output parameters and pointer references as well; however, I am not able to figure out the suitable way to use typemaps to resolve this problem, or any other workaround. Please suggest if i am doing something wrong, or how to use typemap in such situation?

    Read the article

  • Swig: No Constructor defined

    - by wheaties
    I added %allowexcept to my *.i file when building a Python <-- C++ bridge using Swig. Then I removed that preprocessing directive. Now I can't get the Python produced code to recognize the constructor of a C++ class. Here's the class file: #include <exception> class Swig_Foo{ public: Swig_Foo(){} virtual ~Swig_Foo(){} virtual getInt() =0; virtual throwException() { throw std::exception(); } }; And here's the code Swig produces from it: class Swig_Foo: __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, Swig_Foo, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, Swig_Foo, name) def __init__(self): raise AttributeError, "No constructor defined" __repr__ = _swig_repr __swig_destroy__ = _foo.delete_Swig_Foo __del__ = lambda self : None; def getInt(*args): return apply(_foo.Swig_Foo_getInt, args) def throwOut(*args): return apply(_foo.Swig_Foo_throwOut, args) Swig_Foo_swigregister = _foo.Swig_Foo_swigregister Swig_Foo_swigregister(Swig_Foo) The problem is the def __init__self): raise AttributeError, "No constructor defined" portion. It never did this before I added the %allowexception and now that I've removed it, I can't get it to create a real constructor. All the other classes have actual constructors. Quite baffled. Anyone know how I can get it to stop doing this?

    Read the article

  • Simple typemap example in swig java

    - by celil
    I am trying to wrap a native C++ library using swig, and I am stuck at trying to convert time_t in C, to long in Java. I have successfully used swig with python, but so far I am unable to get the above typemap to work in Java. In python it looks like this %typemap(in) time_t { if (PyLong_Check($input)) $1 = (time_t) PyLong_AsLong($input); else if (PyInt_Check($input)) $1 = (time_t) PyInt_AsLong($input); else if (PyFloat_Check($input)) $1 = (time_t) PyFloat_AsDouble($input); else { PyErr_SetString(PyExc_TypeError,"Expected a large number"); return NULL; } } %typemap(out) time_t { $result = PyLong_FromLong((long)$1); } I guess the in map from Java to C would be: %typemap(in) time_t { $1 = (time_t) $input; } How would I complete the out map from C to Java? %typemap(out) time_t ??? Would I need typemaps like the ones below? %typemap(jni) %typemap(jtype) %typemap(jstype) I need this in order to wrap C functions like this: time_t manipulate_time (time_t dt);

    Read the article

  • Define a swig interface file for generation of wrapper to every type from some header file

    - by Dmitriy Matveev
    Hi! We're using some C library in our Java project. Several years ago some other developer which has retired few years ago (as always) has created all the wrappers for us. The wrappers were generated by the swig, but the interface file is lost now. The basic idea of library and the wrappers for it is following: There only one function which returns pointer to some complex object. And there are wrapper for that function. The complex object is a tree-like structure with dozens of node kinds and types (C structures) used to represent them. There are hundreds of wrappers for every field of every type and we're trying to use them all. The library was updated some time ago and now there are some new data we unaware of which yet, but would like to use. This data is contained in some of the objects indirectly contained or referenced from the object created by the function we call (Some new fields and types were added). I know that I shouldn't make any changes to the wrappers by hand and should rather modify the interface, but as I already wrote it's missing. For now I only want to generate wrappers some few types which are added/changed and them to our old wrappers, but later I want to start creation of interface file which will define "what and how should be wrapped". All the definitions necessary for us are defined in single header file. Is it possible to tell swig to generate wrappers for every type in this header? If so, how can I write such interface file?

    Read the article

1 2 3 4 5  | Next Page >