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.
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.
Saji N Hameed,
ARC-ENV, Center for Advanced Information Science and Technology,
University of Aizu, Tsuruga, Ikki-machi,
Aizuwakamatsu-shi, Fukushima 965-8580,
Japan
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.
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.
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’
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.