Reputation:
What is the easiest way to use a custom DLL from within Ruby ?
In Python I would use ctypes, just as described as in this example. But now how should I do it in Ruby, preferably using native functionalities over third party libs ? Is there any way Ruby can be as simple as Python for manipulating a DLL ?
Thank you o/
Upvotes: 4
Views: 5827
Reputation: 6361
Try Ruby's FFI
module.
Two examples to get you started:
The older DL
module seems to be less used and not as easy.
Upvotes: 2
Reputation: 79723
Have a look at the dl
module in the standard library. It’s not brilliantly documented, but the example there should point you in the right direction.
Ruby used to have a Win32API
module for use in Windows, but that has been deprecated now so you should just use dl
directly.
Upvotes: 0