chaudard
chaudard

Reputation: 1

Why do i receive en error message when i open a dll library with ruby, using fiddle?

On windows 10, i am using ruby 2.7.0.

Using 'fiddle', I try to open a dll in my ruby script but i receive an error message on line "Fiddle.dlopen". There is my ruby code :

require 'fiddle'

filename = File.join(__dir__, "Circle.dll")
circle = Fiddle.dlopen(filename)

compute_ray = Fiddle::Function.new(
  circle['ComputeRay'],
  [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE],
  Fiddle::TYPE_DOUBLE
)

r = compute_ray.call(100,5)
puts "ray = #{r}"

"Circle.dll" has been compiled from this repo : https://github.com/chaudard/Circle

There is the error message :

Traceback (most recent call last):
    3: from use_dll.rb:6:in `<main>'
    2: from /usr/lib/ruby/2.7.0/fiddle.rb:47:in `dlopen'
    1: from /usr/lib/ruby/2.7.0/fiddle.rb:47:in `new'
/usr/lib/ruby/2.7.0/fiddle.rb:47:in `initialize': /home/user/code/ruby/dll/Circle.dll: Exec format error (Fiddle::DLError)

Thanks for your help.

Upvotes: 0

Views: 220

Answers (0)

Related Questions