using mruby, how to open an external .dll (build from C/C++)

I am working on a project using mruby. I have a requirement which requires me to load an external .dll and call it’s functions. I have few quires here:

  1. Do I need to build the .dll in any particular format (similar to python)?
  2. I found an example for ruby which uses the Win32API library. Example is given below:

C code:

extern "C" __declspec(dllexport) int helloworld(void)
{
    return 42;
}

mRuby code:

myFunc =  Win32API.new("test.dll", "helloworld", "", "L")
resultMyFunc = myFunc.call()

But when I try to run this with mRuby I get this error:

uninitialized constant Win32API (NameError)

Am I missing any mruby gem? Can someone help me with this please? How do I include the Win32API in my mruby code? Or in mruby is there any other way to load the external .dll and trigger a method.


Source: dll

Leave a Reply