swig

Using C++ standard streams in binary mode through Swig/Python on MinGW

主宰稳场 提交于 2019-12-11 00:08:51
问题 I have a library written with C++ that uses standard streams to read and write objects. I also have a Python interface generated with Swig that I'm using to access the library. Everything works fine on Linux, but on Windows (on MinGW) it seems impossible to use C++ standard streams in binary mode through the Python interface. If the streams are used in text mode, the extra CR characters break the library. The standard streams are fully wrapped inside the C++ library, i.e. I'm not passing them

UnsatisfiedLinkError calling JNI generated by SWIG?

霸气de小男生 提交于 2019-12-10 22:46:54
问题 I'm trying to create a C dynamic library that's callable from Java. I've compiled a DLL under Cygwin, using SWIG to generate the JNI with the following makefile: CC= gcc -mno-cygwin SWIG= /cygdrive/c/Documents\ and\ Settings/student/Desktop/swigwin-2.0.4/swig.exe -java INCLUDE1= -I/cygdrive/c/Program\ Files/Java/jdk1.6.0_25/include INCLUDE2= -I/cygdrive/c/Program\ Files/Java/jdk1.6.0_25/include/win32 utilities: ${SWIG} utilities.i ${CC} -c utilities.c utilities_wrap.c ${INCLUDE1} ${INCLUDE2}

How to pass double[] from c# to c++ using SWIG

别等时光非礼了梦想. 提交于 2019-12-10 22:12:34
问题 I have a c++ class and a member function uses two double array as input like: class model{ //define some varible.. void Trainmodel(double *x,double *y); //... }; I wanted to use this class in c# and followed the example in ./swigwin2.0.9/examples/csharp/arrays and the guide in help page: SWIG my model.MY file is like: %module model_dll %{ /* Includes the header in the wrapper code */ #include "model.h" %} /* Parse the header file to generate wrappers */ %include "model.h" %include "arrays

Creating Windows DLL from C++ source files

泪湿孤枕 提交于 2019-12-10 20:49:12
问题 I have multiple source files in C++ using which i want to create a Dynamic link library. I see this happening in linux with gcc -shared and ln however for Windows i suppose i would have to modify source files to generate a DLL. Is there a way to generate DLL (a file similar to *.so in linux) with provided source files. Please correct me if i m wrong, i think *so is dll for linux. The reason for needing this is to use SWIG for calling C++ functions in python in Windows Platfrom. I am stuck at

swig, python and wchar_t problem

…衆ロ難τιáo~ 提交于 2019-12-10 20:39:46
问题 I am new to the Python C binding swig and have been trying to solve this problem for a while now. I have an external C library (Example.c) that I would like to call from Python. I read Swig tutorial and able to generate the wrapper in no time. The problem now is that when I invoke the API and I got this: >>> import Example >>> dir(Example) ['Example_CreateConnection', 'trimmed to fit the screen'] >>> Example.Example_CreateConnection("") Traceback (most recent call last): File "<stdin>", line

can't compile openssl because of 'cl' is not recognized

纵然是瞬间 提交于 2019-12-10 17:44:03
问题 I am trying to compile openssl library for python script. I am using Windows x64 bit. I am now following steps in this like: https://github.com/dsoprea/M2CryptoWindows It worked till I type this command nmake -f ms\ntdll.mak in the Developer Command Prompt for VS 2015. I am getting this error: 'cl' is not recognized as an internal or external command, operable program or batch file. NMAKE : fatal error U1077: 'cl' : return code '0x1' Stop. I looked in the previous posts in this forum.

How to pass strings to C++ function from Java using SWIG generated interface

痴心易碎 提交于 2019-12-10 16:47:48
问题 I have a bunch of C++ functions that take C std:string as function parameters. I want to pass java Strings to those functions. I have generated a SWIG JNI interface between Java and C++. I can see the no-args constructor fine, but if I try to compile my java with the String arguments in the constructor, I get "cannot find symbol" and I think it is because of something funny going on with the way the class constructor was defined. How do you remedy this problem? Is a typemap the answer? If so

swig typemap for python: input and output arrays

戏子无情 提交于 2019-12-10 16:40:26
问题 I have a C function I want to use in Python: extern int convertAtoB( stateStruct *myStruct, const double PointA[3], double PointB[3]); Using SWIG, I think I need to define a typemap to convert the two points (PointA the input, PointB the output) so that Python can use it. There doesn't seem to be a typemap in typemaps.i that works with this, so I have to define one. I can't seem to find examples of this for arrays in the SWIG documentation. I would like to use this library like so: s =

Calling a Python function in C++ with Swig

南笙酒味 提交于 2019-12-10 16:38:54
问题 Here is my c++ code: void callMethod(void (*someMethod)()) { (*someMethod)(); } My Swig .i file is: %module test %{ #define SWIG_FILE_WITH_INIT extern void callMethod(void (*someMethod)()); %} %typemap (in) void* %{ $1 = PyCObject_AsVoidPtr($input); %} extern void callMethod(void (*someMethod)()); Here is my error: In [1]: import test In [2]: b=test.callMethod In [3]: def func(): ...: print "hi" ...: ...: In [4]: b(func) ------------------------------------------------------------------------

Make a C++ class look like a numpy array using swig

萝らか妹 提交于 2019-12-10 16:38:21
问题 What's a good way to expose a C++ class that provides an array-like interface for use with numpy (scipy)? By array-like interface I mean something like: //file:Arr.h class Arr{ public: int n_rows; int n_cols; float* m_data; Arr(int r, int c, float v); virtual ~Arr(); float get(int i, int j); void set(int i, int j, float v); long data_addr(){ return (long)(m_data); } }; Constraints: I only care about classes that store their underlying data as contiguous flat arrays, The class will provide