Search Results

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

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

  • Compiling C-dll for Python OR SWIG-module creation, how to continue ??

    - by ljuju
    I reference this file "kbdext.c" and its headerfile listed on http://www.docdroppers.org/wiki/index.php?title=Writing_Keyloggers (the listings are at the bottom). I've been trying to compile this into a dll for use in Python or Visual Basic, but have not succeeded. I'm not familiar with C or GCC to sort out the problems or do the dll compile correctly. (I also get an error about snprintf not being declared when doing a regular compile of all the files). What are the steps I should do to make all functions available for other languages and external apps? Or is it perhaps easier to use SWIG and make a python module, instead of compiling a DLL?

    Read the article

  • How can I get swig to wrap a linked list-type structure?

    - by bk
    Here's what I take to be a pretty standard header for a list. Because the struct points to itself, we need this two-part declaration. Call it listicle.h: typedef struct _listicle listicle; struct _listicle{ int i; listicle *next; }; I'm trying to get swig to wrap this, so that the Python user can make use of the listicle struct. Here's what I have in listicle.i right now: %module listicle %{ #include "listicle.h" %} %include listicle.h %rename(listicle) _listicle; %extend listicle { listicle() {return malloc (sizeof(listicle));} } As you can tell by my being here asking, it doesn't work. All the various combinations I've tried each fail in their own special way. [This one: %extend defined for an undeclared class listicle. Change it to %extend _listicle (and fix the constructor) and loading in Python gives type object '_listicle' has no attribute '_listicle_swigregister'. And so on.] Suggestions?

    Read the article

  • Python: Is there a way to reflectivly list all attributes of a class

    - by hhafez
    Given a class such as def MyClass text = "hello" number = 123 Is there a way in python to inspect MyClass an determine that it has the two attributes text and number. I can not use something like inspect.getSource(object) because the class I am to get it's attributes for are generate using SWIG (so they are hidden in .so :) ). So I am really looking for something equivalant to Java's [Class.getDeclardFields][1] Any help would be appreciated, otherwise I'll have to solve this problem with SWIG + JAVA instead of SWIG + Python.

    Read the article

  • Error with swig: undefined symbol: _ZN7hosters11hostersLink7getLinkEi

    - by Eduardo
    I'm trying to make a python binding for the this library: http://code.google.com/p/hosterslib/. I'm using swig, heres is the code: %module pyhosters %{ include "hosters/hosters.hpp" %} %include "hosters/hosters.hpp" I run "swig -c++ -python -o swig_wrap.cxx swig.i" and I compile with "g++ -O2 -fPIC -shared -o _pyhosters.so swig_wrap.cxx python-config --libs --cflags -lhosters -lcln -lhtmlcxx pkg-config libglog --libs --cflags -I/usr/include/python2.6 -Wall -Wextra" But when I run python and I import it, I get: import pyhosters Traceback (most recent call last): File "", line 1, in File "./pyhosters.py", line 7, in import _pyhosters ImportError: ./_pyhosters.so: undefined symbol: _ZN7hosters11hostersLink7getLinkEi How can I solve that? Thanks.

    Read the article

  • Using custom Qt subclasses in Python

    - by kwatford
    First off: I'm new to both Qt and SWIG. Currently reading documentation for both of these, but this is a time consuming task, so I'm looking for some spoilers. It's good to know up-front whether something just won't work. I'm attempting to formulate a modular architecture for some in-house software. The core components are in C++ and exposed via SWIG to Python for experimentation and rapid prototyping of new components. Qt seems like it has some classes I could use to avoid re-inventing the wheel too much here, but I'm concerned about how some of the bits will fit together. Specifically, if I create some C++ classes, I'll need to expose them via SWIG. Some of these classes likely subclass Qt classes or otherwise have Qt stuff exposed in their public interfaces. This seems like it could raise some complications. There are already two interfaces for Qt in Python, PyQt and PySide. Will probably use PySide for licensing reasons. About how painful should I expect it to be to get a SWIG-wrapped custom subclass of a Qt class to play nice with either of these? What complications should I know about upfront?

    Read the article

  • segfault during __cxa_allocate_exception in SWIG wrapped library

    - by lefticus
    While developing a SWIG wrapped C++ library for Ruby, we came across an unexplained crash during exception handling inside the C++ code. I'm not sure of the specific circumstances to recreate the issue, but it happened first during a call to std::uncaught_exception, then after a some code changes, moved to __cxa_allocate_exception during exception construction. Neither GDB nor valgrind provided any insight into the cause of the crash. I've found several references to similar problems, including: http://wiki.fifengine.de/Segfault_in_cxa_allocate_exception http://forums.fifengine.de/index.php?topic=30.0 http://code.google.com/p/osgswig/issues/detail?id=17 https://bugs.launchpad.net/ubuntu/+source/libavg/+bug/241808 The overriding theme seems to be a combination of circumstances: A C application is linked to more than one C++ library More than one version of libstdc++ was used during compilation Generally the second version of C++ used comes from a binary-only implementation of libGL The problem does not occur when linking your library with a C++ application, only with a C application The "solution" is to explicitly link your library with libstdc++ and possibly also with libGL, forcing the order of linking. After trying many combinations with my code, the only solution that I found that works is the LD_PRELOAD="libGL.so libstdc++.so.6" ruby scriptname option. That is, none of the compile-time linking solutions made any difference. My understanding of the issue is that the C++ runtime is not being properly initialized. By forcing the order of linking you bootstrap the initialization process and it works. The problem occurs only with C applications calling C++ libraries because the C application is not itself linking to libstdc++ and is not initializing the C++ runtime. Because using SWIG (or boost::python) is a common way of calling a C++ library from a C application, that is why SWIG often comes up when researching the problem. Is anyone out there able to give more insight into this problem? Is there an actual solution or do only workarounds exist? Thanks.

    Read the article

  • In Python, how to use a C++ function which returns an allocated array of structs via a ** parameter?

    - by Jon-Eric
    I'd like to use some existing C++ code, NvTriStrip, in a Python tool. SWIG easily handles the functions with simple parameters, but the main function, GenerateStrips, is much more complicated. What do I need to put in the SWIG interface file to indicate that primGroups is really an output parameter and that it must be cleaned up with delete[]? /////////////////////////////////////////////////////////////////////////// // GenerateStrips() // // in_indices: input index list, the indices you would use to render // in_numIndices: number of entries in in_indices // primGroups: array of optimized/stripified PrimitiveGroups // numGroups: number of groups returned // // Be sure to call delete[] on the returned primGroups to avoid leaking mem // bool GenerateStrips( const unsigned short* in_indices, const unsigned int in_numIndices, PrimitiveGroup** primGroups, unsigned short* numGroups, bool validateEnabled = false ); FYI, here is the PrimitiveGroup declaration: enum PrimType { PT_LIST, PT_STRIP, PT_FAN }; struct PrimitiveGroup { PrimType type; unsigned int numIndices; unsigned short* indices; PrimitiveGroup() : type(PT_STRIP), numIndices(0), indices(NULL) {} ~PrimitiveGroup() { if(indices) delete[] indices; indices = NULL; } };

    Read the article

  • Load a dll library on Java

    - by crimson_king
    I need to load a library written in C on java. I have only dlls and header files. Since I didn't understand how to translate pointers or other derivated types from JNI documentation I tried to use an automating tool for this, gluegen and SWIG, but I couldn't manage on how to use them. I tried to create an interface file for SWIG but it only gives errors. Is there an example on how to load a dll to a java program using ANY tool that works and can generate translated C function and types from .h files ?

    Read the article

  • Adaptive Threshold in OpenCV (Version 1 - the swig version)

    - by Neil Benn
    Hello I'm trying to get adaptive thresholding working in the python binding to opencv (the swig one - cannot get opencv 2.0 working as I am using a beagleboard as the cross compiling is not working yet). I have a greyscale image (ccg.jpg) and the following code import opencv from opencv import highgui img = highgui.cvLoadImage("ccg.png") img_bw = opencv.cvCreateImage(opencv.cvGetSize(img), opencv.IPL_DEPTH_8U, 1) opencv.cvAdaptiveThreshold(img, img_bw, 125, opencv.CV_ADAPTIVE_THRESH_MEAN_C, opencv.CV_THRESH_BINARY, 7, 10) When I run this I get the error: RuntimeError: openCV Error: Status=Formats of input arguments do not match function name=cvAdaptiveThreshold error messgae= file_name=cvadapthresh.cpp line=122 I've also tried having both the source and dest arguments both the same (greyscale) and I get the error 'Unsupported format or combination of formats'. Does anyone have any clues as to where I could be going wrong? Cheers, Neil

    Read the article

  • How do I make C++/wxWidgets code accessible to a wxPython app?

    - by Jon Cage
    I have a code library which is written in C++ and makes extensive use of the wxWidgets library. I'm now trying to wrap my library (currently using SWIG) so that it's callable from wxPython, but I've hit a wall: ------ Build started: Project: MyLibLib, Configuration: Release_SWIG_OutputForBin Win32 ------ Performing Custom Build Step In order to function correctly, please ensure the following environment variables are correctly set: PYTHON_INCLUDE: C:\Python26\include PYTHON_LIB: C:\Python26\libs\python26.lib d:\MyProject\Software\MyLib\trunk\MyLib>C:\swigwin-2.0.0\swig.exe -python d:\MyProject\Software\MyLib\trunk\MyLibLib\MyLib.i d:\MyProject\Software\MyLib\trunk\MyLib>if errorlevel 1 goto VCReportError d:\MyProject\Software\MyLib\trunk\MyLib>goto VCEnd Compiling... MyLib_wrap.c C:\wxWidgets-2.8.10\include\wx/wxchar.h(886) : warning C4273: '_snprintf' : inconsistent dll linkage c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(358) : see previous definition of '_snprintf' C:\wxWidgets-2.8.10\include\wx/buffer.h(127) : error C2061: syntax error : identifier 'wxCharBuffer' C:\wxWidgets-2.8.10\include\wx/buffer.h(127) : error C2059: syntax error : ';' C:\wxWidgets-2.8.10\include\wx/buffer.h(127) : error C2449: found '{' at file scope (missing function header?) C:\wxWidgets-2.8.10\include\wx/buffer.h(127) : error C2059: syntax error : '}' C:\wxWidgets-2.8.10\include\wx/buffer.h(127) : error C2059: syntax error : ')' C:\wxWidgets-2.8.10\include\wx/buffer.h(129) : error C2061: syntax error : identifier 'wxWritableCharBuffer' C:\wxWidgets-2.8.10\include\wx/buffer.h(129) : error C2059: syntax error : ';' C:\wxWidgets-2.8.10\include\wx/buffer.h(129) : error C2059: syntax error : ':' C:\wxWidgets-2.8.10\include\wx/buffer.h(134) : error C2061: syntax error : identifier 'wxWCharBuffer' C:\wxWidgets-2.8.10\include\wx/buffer.h(134) : error C2059: syntax error : ';' C:\wxWidgets-2.8.10\include\wx/buffer.h(134) : error C2449: found '{' at file scope (missing function header?) C:\wxWidgets-2.8.10\include\wx/buffer.h(134) : error C2059: syntax error : '}' C:\wxWidgets-2.8.10\include\wx/buffer.h(134) : fatal error C1004: unexpected end-of-file found Build log was saved at "file://d:\MyProject\Software\MyLib\trunk\MyLib\Release_SWIG_OutputForBin\BuildLog.htm" MyLibLib - 13 error(s), 1 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Is there a particular way I should be going about this? I spent some time googling for similar errors, but got none which suggests I'm probably barking up the wrong tree here...? [Edit] Is a dll and ctypes the answer?

    Read the article

  • Why must I use local path rather than 'svn://' with SVN bindings?

    - by Chad Johnson
    I'm using the Ruby SVN bindings built with SWIG. Here's a little tutorial. When I do this @repository = Svn::Repos.open('/path/to/repository') I can access the repository fine. But when I do this @repository = Svn::Repos.open('svn://localhost/some/path') It fails with /SourceCache/subversion/subversion-35/subversion/subversion/libsvn_subr/io.c:2710: 2: Can't open file 'svn://localhost/format': No such file or directory When I do this from the command line, I do get output svn ls svn://localhost/some/path Any ideas why I can't use the svn:// protocol?

    Read the article

  • PHP to C/C++ through CGI script

    - by Peterim
    Hi guys! I realize it's probably something strange, but here is what I have. I have an application (handwriting recognition engine) written in C/C++. This application has Perl wrapper which was made by application's authors using SWIG. My website is written in PHP, so I'm looking for some ways to make PHP work with C/C++ application. The only way I can think of now is to create a CGI script (perl script) which accepts POST request from my website (AJAX request), sends it to the recognition engine through it's Perl wrapper, gets the required data and returns the required data as a response to AJAX request. Do you think it could be done this way? Are there any better solutions? Thank you!

    Read the article

  • Easiest way of unit testing C code with Python

    - by Jon Mills
    I've got a pile of C code that I'd like to unit test using Python's unittest library (in Windows), but I'm trying to work out the best way of interfacing the C code so that Python can execute it (and get the results back). Does anybody have any experience in the easiest way to do it? Some ideas include: Wrapping the code as a Python C extension using the Python API Wrap the C code using SWIG Add a DLL wrapper to the C code and load it into Python using ctypes Add a small XML-RPC server to the c-code and call it using xmlrpclib (yes, I know this seems a bit far-out!) Is there a canonical way of doing this? I'm going to be doing this quite a lot, with different C modules, so I'd like to find a way which is least effort.

    Read the article

  • tool to generate C++ wrapper over java class

    - by Vardhan Varma
    From what I understand, SWIG is to wrap C++/C to make it appear in Java, and javah is to implement certain java functions in C++ ( aka native functions ). Is there a tool which can create a C++ wrapper over a java class, so that the caller. of this c++ wrapper doesn't have to worry about java, for example Input Java is class hw { public void hi() { System.out.println("Hello World"); } } Tools outputs hw.hh ( and some. c++ files ), which can be used as: hw *h = new hw(/*JEnv */ env); h-hi(); Is there a tool available which can do this ?

    Read the article

  • How should I distribute a pre-built perl module, and what version of perl do I build for?

    - by Mike Ellery
    This is probably a multi-part question. Background: we have a native (c++) library that is part of our application and we have managed to use SWIG to generate a perl wrapper for this library. We'd now like to distribute this perl module as part of our application. My first question - how should I distribute this module? Is there a standard way to package pre-built perl modules? I know there is ppm for the ActiveState distro, but I also need to distribute this for linux systems. I'm not even sure what files are required to distribute, but I'm guessing it's the pm and so files, at a minimum. My next question - it looks like I might need to build my module project for each version of perl that I want to support. How do I know which perl versions I should build for? Are there any standard guidelines... or better yet, a way to build a package that will work with multiple versions of perl? Sorry if my questions make no sense - I'm fairly new to the compiled module aspects of perl. CLARIFICATION: the underlying compiled source is proprietary (closed source), so I can't just ship source code and the appropriate make artifacts for the package. Wish I could, but it's not going to happen in this case. Thus, I need a sane scheme for packaging prebuilt binary files for my module.

    Read the article

  • Disassembling with python - no easy solution?

    - by Abc4599
    Hi, I'm trying to create a python script that will disassemble a binary (a Windows exe to be precise) and analyze its code. I need the ability to take a certain buffer, and extract some sort of struct containing information about the instructions in it. I've worked with libdisasm in C before, and I found it's interface quite intuitive and comfortable. The problem is, its Python interface is available only through SWIG, and I can't get it to compile properly under Windows. At the availability aspect, diStorm provides a nice out-of-the-box interface, but it provides only the Mnemonic of each instruction, and not a binary struct with enumerations defining instruction type and what not. This is quite uncomfortable for my purpose, and will require a lot of what I see as spent time wrapping the interface to make it fit my needs. I've also looked at BeaEngine, which does in fact provide the output I need, a struct with binary info concerning each instruction, but its interface is really odd and counter-intuitive, and it crashes pretty much instantly when provided with wrong arguments. The CTypes sort of ultimate-death-to-your-python crashes. So, I'd be happy to hear about other solutions, which are a little less time consuming than messing around with djgcc or mingw to make SWIGed libdisasm, or writing an OOP wrapper for diStorm. If anyone has some guidance as to how to compile SWIGed libdisasm, or better yet, a compiled binary (pyd or dll+py), I'd love to hear/have it. :) Thanks ahead.

    Read the article

  • How should I unit test a code-generator?

    - by jkp
    This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions. I have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did it using TDD, but I've found my tests to be brittle as hell. Because each test essentially wanted to verify that for a given bit of input code (which happens to be a C++ header) I'd get a given bit of outputted code I wrote a small engine that reads test definitions from XML input files and generates test cases from these expectations. The problem is I dread going in to modify the code at all. That and the fact that the unit tests themselves are a: complex, and b: brittle. So I'm trying to think of alternative approaches to this problem, and it strikes me I'm perhaps tackling it the wrong way. Maybe I need to focus more on the outcome, IE: does the code I generate actually run and do what I want it to, rather than, does the code look the way I want it to. Has anyone got any experiences of something similar to this they would care to share?

    Read the article

  • SWIG_NewPointerObj and values always being nil

    - by Tom J Nowell
    I'm using SWIG to wrap C++ objects for use in lua, and Im trying to pass data to a method in my lua script, but it always comes out as 'nil' void CTestAI::UnitCreated(IUnit* unit){ lua_getglobal(L, "ai"); lua_getfield(L, -1, "UnitCreated"); swig_module_info *module = SWIG_GetModule( L ); swig_type_info *type = SWIG_TypeQueryModule( module, module, "IUnit *" ); SWIG_NewPointerObj(L,unit,type,0); lua_epcall(L, 1, 0); } Here is the lua code: function AI:UnitCreated(unit) if(unit == nil) then game:SendToConsole("I CAN HAS nil ?") else game:SendToConsole("I CAN HAS UNITS!!!?") end end unit is always nil. I have checked and in the C++ code, the unit pointer is never invalid/null I've also tried: void CTestAI::UnitCreated(IUnit* unit){ lua_getglobal(L, "ai"); lua_getfield(L, -1, "UnitCreated"); SWIG_NewPointerObj(L,unit,SWIGTYPE_p_IUnit,0); lua_epcall(L, 1, 0); } with identical results. Why is this failing? How do I fix it?

    Read the article

  • How to wrap a C function whose parameters are pointer to structs, so that it can be called from Lua?

    - by pierr
    I have the follwing C function. How should I wrap it so it can be called from a Lua script? typedef struct tagT{ int a ; int b ; } type_t; int lib_a_f_4(type_t *t) { return t->a * t->b ; } I know how to wrapr it if the function parameter type were int or char *. Should I use table type for a C structure? EDIT: I am using SWIG for the wraping , according to this doc, It seems that I should automatically have this funtion new_type_t(2,3) , but it is not the case. If you wrap a C structure, it is also mapped to a Lua userdata. By adding a metatable to the userdata, this provides a very natural interface. For example, struct Point{ int x,y; }; is used as follows: p=example.new_Point() p.x=3 p.y=5 print(p.x,p.y) 3 5 Similar access is provided for unions and the data members of C++ classes. C structures are created using a function new_Point(), but for C++ classes are created using just the name Point().

    Read the article

  • Calling Perl and/or Python from Ruby

    - by Yktula
    Would it be possible to integrate Python (and/or Perl) and Ruby with some degree of transparency? I've looked at http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/ and http://code.google.com/p/ruby-perl/ , but they both seem rather outdated. Perhaps this is not an appropriate approach, but would it be possible to generate a Ruby interface for Python's C API?

    Read the article

  • Calling Python from Ruby

    - by Yktula
    Would it be possible to integrate Python and Ruby with some degree of transparency? I've looked at http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/ , but it seems rather outdated. Perhaps this is not an appropriate approach, but would it be possible to generate a Ruby interface for Python's C API?

    Read the article

  • How do I conditionally compile C code snippets to my Perl module?

    - by mobrule
    I have a module that will target several different operating systems and configurations. Sometimes, some C code can make this module's task a little easier, so I have some C functions that I would like to bind the code. I don't have to bind the C functions -- I can't guarantee that the end-user even has a C compiler, for instance, and it's generally not a problem to failover gracefully to a pure Perl way of accomplishing the same thing -- but it would be nice if I could call the C functions from the Perl script. Still with me? Here's another tricky part. Just about all of the C code is system specific -- a function written for Windows won't compile on Linux and vice-versa, and the function that does a similar thing on Solaris will look totally different. #include <some/Windows/headerfile.h> int foo_for_Windows_c(int a,double b) { do_windows_stuff(); return 42; } #include <path/to/linux/headerfile.h> int foo_for_linux_c(int a,double b) { do_linux_stuff(7); return 42; } Furthermore, even for native code that targets the same system, it's possible that only some of them can be compiled on any particular configuration. #include <some/headerfile/that/might/not/even/exist.h> int bar_for_solaris_c(int a,double b) { call_solaris_library_that_might_be_installed_here(11); return 19; } But ideally we could still use the C functions that would compile with that configuration. So my questions are: how can I compile C functions conditionally (compile only the code that is appropriate for the current value of $^O)? how can I compile C functions individually (some functions might not compile, but we still want to use the ones that can)? can I do this at build-time (while the end-user is installing the module) or at run-time (with Inline::C, for example)? Which way is better? how would I tell which functions were successfully compiled and are available for use from Perl? All thoughts appreciated!

    Read the article

  • Can't install py-subversion on freebsd 8.2

    - by max taldykin
    I'm trying to install python bindings for subversion: # cd /usr/ports/devel/py-subversion # make ===> Patching for py26-subversion-1.6.15 ===> Applying extra patch /usr/ports/devel/py-subversion/../../devel/subversion/files /bindings-patch-subversion--bindings--swig--perl--native--Makefile.PL.in cannot open /usr/ports/devel/py-subversion/../../devel/subversion/files/bindings-patch-subversion--bindings--swig--perl--native--Makefile.PL.in: No such file or directory *** Error code 2 Yes, there is no such file in subversion/files, but there is file patch-subversion::bindings::swig::perl::natives::Makefle.PL.in (with colons instead of hyphens). After renaming and rerunning make I got another error: # make ===> Patching for py26-subversion-1.6.15 ===> Applying extra patch /usr/ports/devel/py-subversion/../../devel/subversion/files/bindings-patch-subversion--bindings--swig--perl--native--Makefile.PL.in cannot open /usr/ports/devel/py-subversion/../../devel/subversion/files/bindings-patch-subversion--bindings--swig--perl--native--Makefile.PL.in: No such file or directory *** Error code 2 But now there is nothing like bindings-* in subversion/files. So, the question is why is it so and how can I install py-subversion? PS: FreeBSD is running on virtual private server, so I think it is somehow patched. # uname -a FreeBSD mskhug.ru 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0 r50: Thu Feb 24 10:15:34 IRKT 2011 [email protected]:/root/src/sys/amd64/compile/DEBUG amd64

    Read the article

< Previous Page | 1 2 3 4 5  | Next Page >