My C program calls a third-party Windows DLL to provide access to some specialised hardware. I don't have source code for this DLL. We're losing access to the hardware soon but we want to be able to test our software via an emulator. I'd like to write the emulator in Ruby. So I need a simple way to call Ruby from C - a bit like a reverse SWIG. I can do it using an RPC mechanism to a separate process, but I was wondering if anybody knew of a simpler way. Something where a Ruby library ran in the same process as the C code would be ideal. Any ideas please? Thanks, Graham.
on 2012-11-13 02:20
on 2012-11-13 18:37
On Tue, 2012-11-13 at 09:43 +0900, Graham Menhennitt wrote: > My C program calls a third-party Windows DLL to provide access to some specialised hardware. I don't have source code for this DLL. We're losing access to the hardware soon but we want to be able to test our software via an emulator. I'd like to write the emulator in Ruby. > > So I need a simple way to call Ruby from C - a bit like a reverse SWIG. I can do it using an RPC mechanism to a separate process, but I was wondering if anybody knew of a simpler way. Something where a Ruby library ran in the same process as the C code would be ideal. > > Any ideas please? > > Thanks, > Graham. http://www.ruby-doc.org/docs/ProgrammingRuby/html/... scroll down to Embedding a Ruby Interpreter or google embedding ruby in C for other examples
on 2012-11-13 19:12
If I am not mistaken, the subtle window manager embeds ruby within its C code. http://subforge.org/projects/subtle/repository On Wed, Nov 14, 2012 at 2:37 AM, Reid Thompson <Reid.Thompson@ateb.com>wrote: > > > or google > embedding ruby in C > for other examples > > > > -- Saji N Hameed, ARC-ENV, Center for Advanced Information Science and Technology, University of Aizu, Tsuruga, Ikki-machi, Aizuwakamatsu-shi, Fukushima 965-8580, Japan Tel: +81242 37-2736 Fax:+81242 37-2760 email: saji@u-aizu.ac.jp url: http://www.u-aizu.ac.jp bib: http://www.researcherid.com/rid/B-9188-2009
on 2012-11-15 11:30
On 13/11/2012 11:43, Graham Menhennitt wrote:
> So I need a simple way to call Ruby from C - a bit like a reverse SWIG. I can do
it using an RPC mechanism to a separate process, but I was wondering if anybody
knew of a simpler way. Something where a Ruby library ran in the
Many thanks to Reid and Saji for replying. I have the embedded Ruby
library working and I'm starting on my emulator.
Thanks again,
Graham
on 2012-11-19 02:28
Graham Menhennitt wrote in post #1084538: > Many thanks to Reid and Saji for replying. I have the embedded Ruby > library working and I'm starting on my emulator. > > Thanks again, > Graham That's great that you got it working. I am trying to accomplish the same thing. Would you be willing to describe to me how you did it? I am tearing my hair out trying to figure it out. Regards, Justin
on 2012-11-19 08:03
On 19/11/2012 12:29, Justin Workman wrote: > Graham Menhennitt wrote in post #1084538: >> Many thanks to Reid and Saji for replying. I have the embedded Ruby >> library working and I'm starting on my emulator. >> thing. Would you be willing to describe to me how you did it? I am >> tearing my hair out trying to figure it out. >> It worked pretty much exactly by the book (http://media.pragprog.com/titles/ruby3/ext_ruby.pdf). I'm building on Centos5 Linux and I needed to add a few libraries to the link command: -lpthread -lcrypt -ldl -lrt. I'm trying to work out how to get a Windows build going using MSys, MingW or Visual Studio. If anybody has any hints, it would be appreciated. Graham
on 2012-11-19 08:08
Graham Menhennitt wrote in post #1085110: > I'm trying to work out how to get a Windows build going using MSys, > MingW or Visual Studio. If anybody has any hints, it would be > appreciated. > > Graham Yeah, that is what I'm trying to do. So far no luck in Visual Studio. I was able to get an executable to compile and link with MinGW/MSys, but when I run the program I get this: $ ./test_ruby.exe <internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError) from <internal:gem_prelude>:1:in `<compiled>'
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.