# Very new to Ruby--needs help

**URL:** <https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675>\
**Category:** Ruby\
**Created:** [December 19, 2005, 10:30pm UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675 "2005-12-19T22:30:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [December 19, 2005, 10:30pm UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675/1 "2005-12-19T22:30:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [December 20, 2005, 12:03am UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675/2 "2005-12-20T00:03:42Z")

</div>

Beginner wrote:

> 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

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [December 20, 2005, 2:30pm UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675/3 "2005-12-20T14:30:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [December 20, 2005, 3:39pm UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675/4 "2005-12-20T15:39:33Z")

</div>

Beginner wrote:

> Mankan

The “require” statement loads Ruby extensions, either those written in  
pure Ruby or those written in C using the Ruby extension API. So you  
can’t use it to interface to an arbitrary .dll or .lib file.

There is a Ruby library that allows you to call functions in .dll files,  
though. Check out the Win32API class:  
[http://www.rubycentral.com/book/lib\_windows.html](http://www.rubycentral.com/book/lib_windows.html)

You might also learn more about the Win32API library by searching  
through old postings to this list. Search for “Win32API”.

Welcome to Ruby!

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [December 20, 2005, 3:24pm UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675/5 "2005-12-20T15:24:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [December 20, 2005, 4:48pm UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675/6 "2005-12-20T16:48:47Z")

</div>

Thank you Timothy and Patrick, I got the answer to what I am looking  
for.

-Mankna

---

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [December 20, 2005, 3:57pm UTC](https://www.ruby-forum.com/t/very-new-to-ruby-needs-help/50675/7 "2005-12-20T15:57:37Z")

</div>

On 12/20/05, Beginner [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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](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
