swig

Swig a DLL into Java

余生长醉 提交于 2019-12-19 10:29:14
问题 Does anybody know whether it's possible to use Swig to generate a Java interface for a DLL with bundled C headers? There're many tutorials describing what to do if you have the source (http://www.swig.org/Doc1.3/Java.html). 回答1: All of the information in the tutorial you linked to is still relevant even if you only have header files and a DLL. All you need is the headers and a library to link against it. You have two choices then. Either you can make your build process link the SWIG generated

Swig a DLL into Java

半腔热情 提交于 2019-12-19 10:28:59
问题 Does anybody know whether it's possible to use Swig to generate a Java interface for a DLL with bundled C headers? There're many tutorials describing what to do if you have the source (http://www.swig.org/Doc1.3/Java.html). 回答1: All of the information in the tutorial you linked to is still relevant even if you only have header files and a DLL. All you need is the headers and a library to link against it. You have two choices then. Either you can make your build process link the SWIG generated

SWIG: Wrapping C++ for Perl using only a header and a shared library, can't locate loadable object error

随声附和 提交于 2019-12-19 08:52:08
问题 I'm trying to learn SWIG and I'm having some issues getting SWIG to work with perl on a Linux machine. I have the files Dog.h, Crow.h, Animal.i, and libmylib.so. All these files are in the same directory. libmylib.so was compiled using Dog.cpp and Crow.cpp, which reference Dog.h and Crow.h respectively. My Animal.i file is as follows: %module Animal %{ /* Includes the header in the wrapper code */ #include "Dog.h" #include "Crow.h" %} /*Parse the header file to generate wrappers */ %include

Using SWIG to convert C++ char* as char[] in Java instead of String

给你一囗甜甜゛ 提交于 2019-12-19 07:51:14
问题 I am attempting to wrap the following C++ function with Java: char* MyClass::to_cstring(); This output of this function is returned as a Java String object. I would like it to return as a char[] Java array. I am currently using "typemaps.i" and "std_string.i". Is there a way to override the behavior such that std::string is still returned as a Java String , but char* is returned as a Java char array? How about using Java byte[] instead of char[] so there is not need to worry about translating

Not able to run SWIG C# examples in VS 2010

萝らか妹 提交于 2019-12-19 03:56:08
问题 I am trying to get SWIG to work with Visual Studio and C#. I downloaded swigwin-2.0.4.zip and converted the project to a VS 2010 project. I am able to build the 'class' example. When I then try to run compiled build I get the error The type initializer for 'examplePINVOKE' threw an exception. I haved googled the error, but have not found any suggestions on how to resolve it. Hope somebody is able to help! Thanks, Christian 回答1: What worked for me was to: Go to Build->Configuration Manager.

SWIG passing argument to python callback function

独自空忆成欢 提交于 2019-12-18 17:00:32
问题 So I'm almost done. Now I have working code which calls python callback function. Only thing I need now is how to pass argument to the python callback function. My callback.c is: #include <stdio.h> typedef void (*CALLBACK)(void); CALLBACK my_callback = 0; void set_callback(CALLBACK c); void test(void); void set_callback(CALLBACK c) { my_callback = c; } void test(void) { printf("Testing the callback function\n"); if (my_callback) (*my_callback)(); else printf("No callback registered\n"); } My

Error when trying to cross-compile SWIG Python extension for mingw32 using distutils

你离开我真会死。 提交于 2019-12-18 13:36:49
问题 I am trying to cross-compile a simple SWIG Python extension on Linux for Windows (mingw32), using the distutils module. The ultimate goal is to compile a Python wrapper for some library and being able to use it on Windows. Obviously I started with the most basic example and unfortunately it fails. Here are the files I am using: example.c /* File : example.c */ /* A global variable */ double Foo = 3.0; /* Compute the greatest common divisor of positive integers */ int gcd(int x, int y) { int g

wrapping specialised c++ template class with swig

ぐ巨炮叔叔 提交于 2019-12-18 13:34:05
问题 consider the following class declarations: namespace X { template<class T> class Foo { public: Foo(); virtual ~Foo(); T value() const; }; template<class T> class Foo<vector<T>> { public: Foo(); virtual ~Foo(); T value( const int ) const; }; } for them i have the following declaration in the foo.i file %include "stl.i" %include "std_string.i" %include "std_vector.i" namespace X { using namespace std; template<class T> class Foo { public: Foo(); virtual ~Foo(); T value() const; }; template

Correct way to interact with arrays using SWIG

六月ゝ 毕业季﹏ 提交于 2019-12-18 13:30:42
问题 I'm a bit lost with typemaps in swig and how to use arrays. I have prepared a working example that uses arrays between java and c using swig, but i don't know if it is the correct way to do it. Basically i want to pass a byte array byte[] from java to c as a ´signed char *` + it's size, modify it in c and see the changes in java and create an array in c and use it in Java. I have take a look at theese questions: How to pass array(array of long in java) from Java to C++ using Swig, Pass an

What are the best practices when using SWIG with C#?

非 Y 不嫁゛ 提交于 2019-12-18 11:53:23
问题 Has anybody out there used the SWIG library with C#? If you have, what pitfalls did you find and what is the best way to use the library? I am thinking about using it as a wrapper for a program that was written in C and I want to wrap the header files where I can use them in my .NET application. Edit: Some clarification on target OS's. I plan on running the application on Linux and Windows, therefore the reason I am looking into SWIG. P/Invoke is not an option. 回答1: I think the mistake the