Hi
I have now produced a dll file, and that dll file is win32api in ruby.I’m trying to get a function of the dll file. However, when Ruby tries to load that dll file, an error message appears.
C:/Ruby25-x64/lib/ruby/2.5.0/fiddle.rb:in ‘initialize’: Exec format error (LoadError)
from C:/from Ruby25-x64/lib/ruby/2.5.0/fiddle.rb:47:in ‘new’
from C:/Ruby25-x64/lib/ruby/2.5.0/fiddle.rb:47:in ‘dlopen’
from C:/Ruby25-x64/lib/ruby/2.5.0/Win32API.rb:28:in ‘rescue initialize’
from C:/Ruby25-x64/lib/ruby/2.5.0/Win32API.rb:24:in ‘initialize’
I also tried AppData\Roaming\SketchUp\SketchUp 2019\SketchUp\Plugins\dll.
I don’t know why such an error comes out. I want you to let me.
I will attach the ruby code and the dll code below.
ruby code
require "Win32API"
dll_path = File.join("C:/Program Files/SketchUp/SketchUp 2019", "bcdf")
aa = Win32API.new(dll_path, 'Message', 'I')
<dll code>
#include "stdio.h"
#include "Header.h"
extern "C"
{
DLL_TEST_API int Example(int a, int b)
{
return a + b;
}
}
<header>
#pragma once
#ifdef BCDF_EXPORTS
#define DLL_TEST_API __declspec(dllexport)
#else
#define DLL_TEST_API __declspec(dllimport)
#endif