[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Include existing C/C++ libraries in Ruby.

Ritesh Tijoriwala

8/4/2006 5:57:00 PM

I want to use my existing C/C++ libraries in Ruby and is there a way to
do that? I tried SWIG but it doesn't work out that good for complex
objects and methods that I have in my libraries. Any other ways to
accomplish this?

--
Posted via http://www.ruby-....

5 Answers

Aria Stewart

8/4/2006 6:01:00 PM

0

On Sat, 2006-08-05 at 02:57 +0900, Ritesh Tijoriwala wrote:
> I want to use my existing C/C++ libraries in Ruby and is there a way to
> do that? I tried SWIG but it doesn't work out that good for complex
> objects and methods that I have in my libraries. Any other ways to
> accomplish this?


I hand-wrap libraries. It's not that hard, and I can micromanage the API
that way.

Aria


Ritesh Tijoriwala

8/4/2006 6:03:00 PM

0

Aredridel wrote:
> On Sat, 2006-08-05 at 02:57 +0900, Ritesh Tijoriwala wrote:
>> I want to use my existing C/C++ libraries in Ruby and is there a way to
>> do that? I tried SWIG but it doesn't work out that good for complex
>> objects and methods that I have in my libraries. Any other ways to
>> accomplish this?
>
>
> I hand-wrap libraries. It's not that hard, and I can micromanage the API
> that way.
>
> Aria

Hello Aria,

Can you demonstrate with some example. It will help me great in
understanding. Appreciate your help.

Ritesh.

--
Posted via http://www.ruby-....

Matt Todd

8/4/2006 6:49:00 PM

0

I have an idea, though I'll honestly say that I don't know if it'll
work: try making some simpler C/C++ libraries, let SWIG do its thing
with those, and see what the code it produces looks like. It's
basically a template or a reference!

Then again, I don't work with Ruby extensions and C/C++ libraries
(though I intend to someday).

M.T.

Ara.T.Howard

8/4/2006 7:16:00 PM

0

Francis Cianfrocca

8/4/2006 7:33:00 PM

0

unknown wrote:
> On Sat, 5 Aug 2006, Ritesh Tijoriwala wrote:
>
>> I want to use my existing C/C++ libraries in Ruby and is there a way to
>> do that? I tried SWIG but it doesn't work out that good for complex
>> objects and methods that I have in my libraries. Any other ways to
>> accomplish this?
>
> you can use them directly with ruby/dl
>

I used to use ruby/dl a lot, and it's vastly better than the equivalent
stuff in Python, although the documentation is inadequate. But more
recently I've gotten in the habit of simply writing plain old Ruby
extensions (lots of good docs, and they are dead-easy) that wrap my
C/C++ code. I think that's the best way, because you can keep all the
ugly stuff in C and your Ruby code stays nice and clean. You have to do
a certain amount of massaging between the C world and the Ruby world,
but it's not hard. Read README.EXT in the ruby source distro.

--
Posted via http://www.ruby-....