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
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
tmprman (1)
|
1/29/2010 8:50:49 PM |
|
On Jan 29, 12:50=A0pm, Rich Maniscalco <tmpr...@gmail.com> wrote:
> Hello,
>
> I am very new to Ruby, as in about 1 week new. =A0General Ruby programmin=
g
> is going well. =A0However, I am having trouble accessing functions in
> non-Windows DLL's. =A0We have custom DLL's used to talk to test equipment=
..
> These DLL's are created in C using Visual C++. =A0They work fine with the
> original C program. =A0I'm want to use Ruby scripts that access these
> DLL's. =A0The documentation gives examples of accessing Windows libraries=
,
> which worked for me. =A0But my stuff is giving me the "`initialize':
> GetProcAddress:" error. =A0I 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? =A0Or
> can someone tell me what I'm doing wrong?
>
> I'm using Ruby 1.8.6 on Windows XP and Cygwin bash shell.
>
> Thanks,
>
> =A0 Rich
> --
> 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-wi=
n32api-library/
|
|
0
|
|
|
|
Reply
|
Philliam
|
1/29/2010 8:58:16 PM
|
|
> 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
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Roger
|
1/29/2010 9:24:24 PM
|
|
Philliam Auriemma wrote:
> On Jan 29, 12:50?pm, Rich Maniscalco <tmpr...@gmail.com> 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
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Rich
|
1/29/2010 9:26:11 PM
|
|
> 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
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Roger
|
1/29/2010 9:29:08 PM
|
|
On Jan 29, 1:26=A0pm, Rich Maniscalco <tmpr...@gmail.com> wrote:
> Philliam Auriemma wrote:
> > On Jan 29, 12:50?pm, Rich Maniscalco <tmpr...@gmail.com> 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-us...
>
> Hi Philliam,
>
> Thanks for the info. =A0I cut-n-pasted those examples and they work for
> me. =A0However, I am trying to call NON Windows API functions. =A0Any tip=
s
> for that?
>
> Thanks,
>
> =A0 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.
|
|
0
|
|
|
|
Reply
|
Philliam
|
1/29/2010 9:36:42 PM
|
|
Roger Pack 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
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Rich
|
1/29/2010 9:37:22 PM
|
|
Rich Maniscalco wrote:
> Roger Pack 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
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Rich
|
1/29/2010 9:41:07 PM
|
|
Philliam Auriemma wrote:
> On Jan 29, 1:26?pm, Rich Maniscalco <tmpr...@gmail.com> 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
--
Posted via http://www.ruby-forum.com/.
|
|
0
|
|
|
|
Reply
|
Rich
|
1/29/2010 10:24:29 PM
|
|
On 29 Jan 2010, at 22:24, Rich Maniscalco wrote:
> That didn't work. I am going to rebuild Ruby and my DLL's using VC++=20=
> version 9. Hopefully that will resolve the issues. I'll report the=20=
> 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
|
|
0
|
|
|
|
Reply
|
Eleanor
|
1/31/2010 2:22:17 PM
|
|
|
9 Replies
335 Views
(page loaded in 0.115 seconds)
|