From: Vladimir Konrad Date: 2006-09-11T22:07:41+09:00 Subject: Re: metakit from ruby using swig 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-forum.com/.