Very new to Ruby--needs help

B

Beginner

Dear Ruby Gurus,

I would like to load a *.lib file into my *.rb file. How to do that. I
did mentioned the path but was not successful. I did this:

load (or require) "PATH name:*.lib"

thx,
Mankan
 
E

Eero Saynatkari

Beginner said:
Dear Ruby Gurus,

I would like to load a *.lib file into my *.rb file. How to do that. I
did mentioned the path but was not successful. I did this:

load (or require) "PATH name:*.lib"

What is in the .lib file?

If it is ruby code (in which case you should just
change it to .rb anyway:),

require "#{path}/foobar.lib"

Should work fine.

If it is object code, I believe ruby can only load
so (and, I assume, .dll) files so you may need to
extract the shared library.

If it is just plain text or something, you would
want to use File.open(filename) {|f| do_something_with f }.

Please clarify a bit and I am sure we can help you
get it working right!
thx,
Mankan


E
 
B

Beginner

Dear Eero,

Thank you very much. it is a low-level APIs named power32.lib and I
would like to call this APIs from ruby to find the hardware parameters
like number of boards etc.

Hence I am looking for loading this power32.lib file and then call the
low-level API from Ruby.

Pls do let me know if the question is still not clear.

thx in advance,
Mankan
 
B

Beginner

Dear Eero,

I am not able to load even .dll, this is what I did:

require "C:\\WINDOWS\\SYSTEM32\\abc.dll"

I am doing anything wrong. The .dll does exist in the directory, I get
the erro, "the specified procedure could not be found".(loadError)

thx,
Mankan
 
P

Patrick Hurley

I am not able to load even .dll, this is what I did:

require "C:\\WINDOWS\\SYSTEM32\\abc.dll"

Is abc.dll the dll associated with power32.lib? Or just an example. I
am unfamiliar (as is at least a cursory Google :) with this
particular library. Without a specific API document, I doubt we can
provide you with the level of detail you will need at this stage in
your programming career.

From a high level there are two ways normally used to access external
libraries from within Ruby:

1. Create an extension -- this requires a certain amount of C
programming either by hand or using something like SWIG.

2. Or using DL (http://ttsky.net/ruby/ruby-dl.html)

If you can provide a specific API for the library you may get some
additional help (even more so if the library in question is free/open
source).

Good Luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top