Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
metakit from ruby using swig
Vladimir Konrad
9/11/2006 9:25:00 AM
i managet to make the metakit (
http://www.equi4.com/me...
) work
from ruby
by using swig. it was my first usage of swig and the result is not
"rubyish", but the basic test works (can store and retrieve data).
is there any interest in this (i.e. would you like the instructions on
how i have done it)?.
vlad
--
Posted via
http://www.ruby-...
.
3 Answers
M. Edward (Ed) Borasky
9/11/2006 12:41:00 PM
0
Vladimir Konrad wrote:
> i managet to make the metakit (
http://www.equi4.com/me...
) work
> from ruby
> by using swig. it was my first usage of swig and the result is not
> "rubyish", but the basic test works (can store and retrieve data).
>
> is there any interest in this (i.e. would you like the instructions on
> how i have done it)?.
>
> vlad
>
I'm interested, although I'm perfectly happy with SQLite and its Ruby
bindings. I'm just starting to get my feet wet with SWIG, so I'm
interested in that as well.
Vladimir Konrad
9/11/2006 1:08:00 PM
0
here it goes...
/* swig file */
%module mk4
%{
#include "mk4.h"
%}
%include "mk4.h"
/* swig file end */
metakit version (the latest .tar.gz from their web-site).
swig version:
SWIG Version 1.3.27
Copyright (c) 1995-1998
University of Utah and the Regents of the University of California
Copyright (c) 1998-2005
University of Chicago
Compiled with g++ [i686-pc-linux-gnu]
ruby version:
ruby 1.8.4 (2005-12-24) [i686-linux]
gcc version:
g++ (GCC) 4.1.1
how to wrap the metakit using swig:
1. build and install metakit (as shared object, i did not try the static
build)
2. cd to "include" directory in the metakit directory
3. create mk4.i
4. # swig -ruby -c++ mk4.i
(it will issue a lot of warnings but it generates the wrapper)
5. # g++ -c mk4_wrap.cxx -I/usr/lib/ruby/1.8/i686-linux
it will give errors but deleting the 4 offending wrapper definitions
(and
4 calls using them) will make it compile
(the -I should point to wherewer the ruby.h resides)
6. # g++ -shared mk4_wrap.o ../builds/libmk4.so -o mk4.so
note, the mk4so will depend on the location of libmk4.so, to build the
"proper" way, copy the mk4_wrap.o and libmk4.so to a common directory,
cd there and do:
# g++ -shared mk4_wrap.o libmk4.so -o mk4.so
(this way, if ld can find the libmk4.so, the mk4.so will load)
7. from ruby:
require 'mk4'
include Mk4 # optional
(the mk4.so has to be somewhere ruby can find it)
notes: i am not sure whether the removal of definitions affects the
function of metakit extension but a basic test works.
vlad
ps: if you are interested, i can send you the generated wrapper (so you
can diff it against yours to see what i removed) + simple test script by
e-mail...
--
Posted via
http://www.ruby-...
.
Vladimir Konrad
9/11/2006 1:30:00 PM
0
forgot one thing, the metakit can be built as static library
(--disable-shared option for configure), and the swig wrapper library
linked against that - this way the ruby shared object (mk4.so) will not
depend on the shared library libmk4.so (basically the ruby mk4.so will
have all the functions of metakit in it)...
vlad
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
metakit from ruby using swig
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password