johan.potums-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-27 13:14 UTC
Wrapping C++ dll in ruby
Hello I''m fairly new to RoR (and Ruby), so please forgive me my possible stupid questions. I have a C++ dll which is like a clientside-accespoint to some webservices (for security reasons). Now I want to address the dll from ruby code, cause I want to do some functional testing on the services it implements. I read a reference to Ruby Native on http://www.gaffer.org/archives/ruby-native-2 but I ''m not sure this is what I want so anybody has an idea, that would be great... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello, Wrapping a C++ DLL is not /that/ difficult but it is not straight. Ruby is only able to access C (read the README.EXT file in the Ruby source code), therefore you need to wrap you C++ in C: Ruby -> C -> C++ You might want to try SWIG (http://www.swig.org), which creates bindings with little effort. The problem with SWIG is the code does not feel like Ruby. Depending on how comprehensive you need your bindings to be and how Ruby you want them to be, it might be easier/better you just write a few C functions wrapping the C++ clasess and methods you need. I don''t know if it''s going to help you, but Ruby/DLX might be useful too: http://ruby-dlx.rubyforge.org/index.xhtml -- Pau Garcia i Quiles http://www.elpauer.org (Due to the amount of work, I usually need 10 days to answer) Quoting "johan.potums-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johan.potums-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Hello > > I''m fairly new to RoR (and Ruby), so please forgive me my possible > stupid questions. > > I have a C++ dll which is like a clientside-accespoint to some > webservices (for security reasons). Now I want to address the dll from > ruby code, cause I want to do some functional testing on the services > it implements. > > I read a reference to Ruby Native on > http://www.gaffer.org/archives/ruby-native-2 > but I ''m not sure this is what I want > > so anybody has an idea, that would be great... > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can also try http://www.gaffer.org/archives/category/ruby/ . It has some good examples of C++ objects bing used in Ruby. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
johan.potums-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-30 06:27 UTC
Re: Wrapping C++ dll in ruby
Thanks a lot! Johan On 27 apr, 17:23, Pau Garcia i Quiles <pgqui...-SAwgbyZpXJFAfugRpC6u6w@public.gmane.org> wrote:> Hello, > > Wrapping aC++DLLis not /that/ difficult but it is not straight. > > Ruby is only able to access C (read the README.EXT file in the Ruby > source code), therefore you need towrapyouC++in C: > > Ruby -> C ->C++ > > You might want to try SWIG (http://www.swig.org), which creates > bindings with little effort. The problem with SWIG is the code does > not feel like Ruby. > > Depending on how comprehensive you need your bindings to be and how > Ruby you want them to be, it might be easier/better you just write a > few C functions wrapping theC++clasess and methods you need. > > I don''t know if it''s going to help you, but Ruby/DLX might be useful > too:http://ruby-dlx.rubyforge.org/index.xhtml > > -- > Pau Garcia i Quileshttp://www.elpauer.org > (Due to the amount of work, I usually need 10 days to answer) > > Quoting "johan.pot...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <johan.pot...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > > Hello > > > I''m fairly new to RoR (and Ruby), so please forgive me my possible > > stupid questions. > > > I have aC++dllwhich is like a clientside-accespoint to some > > webservices (for security reasons). Now I want to address thedllfrom > > ruby code, cause I want to do some functional testing on the services > > it implements. > > > I read a reference to Ruby Native on > >http://www.gaffer.org/archives/ruby-native-2 > > but I ''m not sure this is what I want > > > so anybody has an idea, that would be great...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---