# FreeImage-FFI

**URL:** <https://www.ruby-forum.com/t/freeimage-ffi/182899>\
**Category:** Ruby\
**Created:** [February 4, 2010, 2:41pm UTC](https://www.ruby-forum.com/t/freeimage-ffi/182899 "2010-02-04T14:41:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/90db22/32.png) [@jonty](https://www.ruby-forum.com/u/jonty)\
**Post date:** [February 4, 2010, 2:41pm UTC](https://www.ruby-forum.com/t/freeimage-ffi/182899/1 "2010-02-04T14:41:15Z")

</div>

In view of ImageScience being currently broken on ruby 1.9 I thought it  
would be a good idea to try and use FFI with FreeImage. And lo! this has  
been tried last April, repositories on github.

> **[GitHub - adamsanderson/freeimage-ffi: Ruby FFI for Image Science](https://github.com/adamsanderson/freeimage-ffi)**
>
> Ruby FFI for Image Science. Contribute to adamsanderson/freeimage-ffi development by creating an account on GitHub.

Fine but none of the code I have tried work with the precompiled dll of  
freeImage for windows.

This illustrates my problem:

require ‘ffi’

module TestFreeImage  
extend FFI::Library  
ffi\_lib ‘FreeImage’  
ffi\_convention :stdcall  
attach\_function :getversion, :FreeImage\_GetVersion , [], :char  
end

version=TestFreeImage.getversion

puts “Version is #{version}”

Gives the following error:

`attach_function': Function 'FreeImage_GetVersion' not found in [FreeImage] (FFI::NotFoundError) from testimagescience.rb:7:in `module:TestFreeImage’  
from testimagescience.rb:3:in `’

> Exit code: 1

here is the header from freeimage.h

DLL\_API const char \*DLL\_CALLCONV FreeImage\_GetVersion(void);

When trying the freeimage-ffi tests I get the same error, incidentally I  
had to hack that as it looks for freeimage.3 only. I changed like above

- it seems to be finding the dll ok.  
(in windows/system32)

Can anyone shed light on this? I am not a C programmer
