Newbie question: Accessiong non-Windows DLL's

Hello,

I am very new to Ruby, as in about 1 week new. General Ruby programming
is going well. However, I am having trouble accessing functions in
non-Windows DLL’s. We have custom DLL’s used to talk to test equipment.
These DLL’s are created in C using Visual C++. They work fine with the
original C program. I’m want to use Ruby scripts that access these
DLL’s. The documentation gives examples of accessing Windows libraries,
which worked for me. But my stuff is giving me the “`initialize’:
GetProcAddress:” error. I also created a very basic DLL which just
prints “Hello World” and had the same Ruby error.

Is there a pointer to some documentation/code examples I can read? Or
can someone tell me what I’m doing wrong?

I’m using Ruby 1.8.6 on Windows XP and Cygwin bash shell.

Thanks,

Rich

On Jan 29, 12:50 pm, Rich M. [email protected] wrote:

prints “Hello World” and had the same Ruby error.
Posted viahttp://www.ruby-forum.com/.
I think you may be able to use the Win32API module for that.

http://www.rubytips.org/2008/05/13/accessing-windows-api-from-ruby-using-win32api-library/

Is there a pointer to some documentation/code examples I can read? Or
can someone tell me what I’m doing wrong?

FFI might work.
-r

Philliam A. wrote:

On Jan 29, 12:50?pm, Rich M. [email protected] wrote:

prints “Hello World” and had the same Ruby error.
Posted viahttp://www.ruby-forum.com/.
I think you may be able to use the Win32API module for that.

http://www.rubytips.org/2008/05/13/accessing-windows-api-from-ruby-using-win32api-library/

Hi Philliam,

Thanks for the info. I cut-n-pasted those examples and they work for
me. However, I am trying to call NON Windows API functions. Any tips
for that?

Thanks,

Rich

Roger P. wrote:

which worked for me. But my stuff is giving me the “`initialize’:
GetProcAddress:” error. I also created a very basic DLL which just
prints “Hello World” and had the same Ruby error.
I’m using Ruby 1.8.6 on Windows XP and Cygwin bash shell.

You might get some traction by using a ruby compiled with the same
compiler that made your dll’s, like the old one click installer for MSVC
compiled dll.
-r

Hi Roger,

Thanks for the info. I had installed Ruby using “Ruby 1.8.6 One-Click
Installer” from ruby-lang.org. Are you suggesting I rebuild both Ruby
and my DLL’s? Just checking for clarity.

Thanks,

Rich

which worked for me. But my stuff is giving me the “`initialize’:
GetProcAddress:” error. I also created a very basic DLL which just
prints “Hello World” and had the same Ruby error.
I’m using Ruby 1.8.6 on Windows XP and Cygwin bash shell.

You might get some traction by using a ruby compiled with the same
compiler that made your dll’s, like the old one click installer for MSVC
compiled dll.
-r

Rich M. wrote:

Roger P. wrote:

which worked for me. But my stuff is giving me the “`initialize’:
GetProcAddress:” error. I also created a very basic DLL which just
prints “Hello World” and had the same Ruby error.
I’m using Ruby 1.8.6 on Windows XP and Cygwin bash shell.

You might get some traction by using a ruby compiled with the same
compiler that made your dll’s, like the old one click installer for MSVC
compiled dll.
-r

Hi Roger,

Thanks for the info. I had installed Ruby using “Ruby 1.8.6 One-Click
Installer” from ruby-lang.org. Are you suggesting I rebuild both Ruby
and my DLL’s? Just checking for clarity.

Thanks,

Rich

BTW, my current VC++ is " Microsoft Visual C++ 2008 Express Edition
version 9". Ruby is compiled with 6.0. Will that matter?

Rich

On Jan 29, 1:26 pm, Rich M. [email protected] wrote:

Thanks for the info. I cut-n-pasted those examples and they work for
me. However, I am trying to call NON Windows API functions. Any tips
for that?

Thanks,

Rich

Posted viahttp://www.ruby-forum.com/.

You should be able to make a DLL and have it export the correct
symbols for your functions, and put the DLL file in C:/WINDOWS/
system32 (may be just C:/WINDOWS/ or C:/WINDOWS/system/, can’t
remember) and you can use your own DLL the same way. I’m not sure how
to do it any other way without making your own ruby extension, which I
found impossible.

On 29 Jan 2010, at 22:24, Rich M. wrote:

That didn’t work. I am going to rebuild Ruby and my DLL’s using VC++
version 9. Hopefully that will resolve the issues. I’ll report the
outcome.

I’ve not used Windows for development in about seven years so take the
following with a pinch of salt.

Ruby/DL allows dynamic loading of Windows DLLs and ships as part of
Ruby’s standard library. You’ll find links to what exists in the way of
English documentation in the Ruby Plumber’s Guide to Unix presentation
linked to in my signature, but unfortunately there’s very little
documentation online regarding its use under Windows.

At the least you’ll have to figure out the function signatures for the
DLL routines you want to access by trial and error and there’ll probably
also be issues with type conversion…

An alternative would be to rewrite your DLLs as Windows COM servers so
you could use the WinOLE library to access them.

Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net

raise ArgumentError unless @reality.responds_to? :reason

Philliam A. wrote:

On Jan 29, 1:26?pm, Rich M. [email protected] wrote:

Thanks for the info. ?I cut-n-pasted those examples and they work for
me. ?However, I am trying to call NON Windows API functions. ?Any tips
for that?

Thanks,

? Rich

Posted viahttp://www.ruby-forum.com/.

You should be able to make a DLL and have it export the correct
symbols for your functions, and put the DLL file in C:/WINDOWS/
system32 (may be just C:/WINDOWS/ or C:/WINDOWS/system/, can’t
remember) and you can use your own DLL the same way. I’m not sure how
to do it any other way without making your own ruby extension, which I
found impossible.

That didn’t work. I am going to rebuild Ruby and my DLL’s using VC++
version 9. Hopefully that will resolve the issues. I’ll report the
outcome.

Thanks,

Rich

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs